Perl control flow

ControlFlow Perl Programming Reference

Simple


STATEMENT if      EXPR
STATEMENT unless  EXPR
STATEMENT while   EXPR
STATEMENT until   EXPR
STATEMENT foreach LIST

Loops


if     (EXPR) BLOCK elsif (EXPR) BLOCK else BLOCK
unless (EXPR) BLOCK elsif (EXPR) BLOCK else BLOCK

LABEL: while (EXPR) BLOCK continue BLOCK
LABEL: until (EXPR) BLOCK continue BLOCK

LABEL: foreach (EXPR; EXPR; EXPR) BLOCK

LABEL: foreach VAR (LIST) BLOCK continue BLOCK

LABEL: BLOCK continue BLOCK

PHASE BLOCK

Loop control


next LABEL   # go to next iteration
last LABEL   # exit loop
redo LABEL   # restart current iteration

Notes

Links