Loop control
You can put a label on a loop to give it a name. The
loop’s label identifies the loop for the loop-control commands
next, last, and redo:
LINE: while (<SCRIPT>) {
print;
next LINE if /^#/; # Discard comments
}The syntax for the loop-control commands is:
lastlabelnextlabelredolabel
If the label is omitted, the loop-control command refers to the innermost enclosing loop.
The last command
is like the break statement in
C (as used in loops); it immediately exits the loop in question.
The continue block, if any, is
not executed.
The next command
is like the continue statement
in C; it skips the rest of the current iteration and starts the
next iteration of the loop. If there is a continue block on the loop, it is always
executed just before the conditional is reevaluated.
The redo command
restarts the loop block without evaluating the conditional again.
The continue block, if any, is
not executed.