Perl next,last and goto
Labels
Any statement block can be given a label. Labels are identifiers that follow variable naming rules. They are placed immediately before a statement block and end with a colon:
SOMELABEL: {
statements;
}
You can short-circuit loop execution with the directives next and last:
· next skips the remaining statements in the loop and proceeds to the next iteration (if any)
· last immediately exits the loop in question
· redo jumps to the beginning of the block (restarting current iteration)
Next and last can be used in conjunction with a label to specify a loop by name. If the label is omitted, the presumption is that next/last refers to the innermost enclosing loop.
Usually deprecated in most languages, the goto expression is nevertheless supported by Perl. It is usually used in connection with a label
goto LABEL;
to jump to a particular point of execution.