next 
next LABEL
nextThe next operator is like the continue
statement in C: it starts the next iteration of the loop designated by
LABEL:
LINE: while (<STDIN>) {
next LINE if /^#/; # discard comments
...
}If there were a continue block
in this example, it would be executed immediately following the
invocation of next. When
LABEL is omitted, the operator refers to the
innermost enclosing loop.
A block by itself is semantically identical to a loop that
executes once. Thus, next will exit
such a block early (via the continue
block, if there is one).
next cannot be used to exit a
block that returns a value, such as eval
{}, sub {}, or do {}, and it should not be used to exit a
grep or map operation. With warnings enabled, Perl
warns you if you next out of a loop
not in your current lexical scope, such as a loop in a calling
subroutine. See the section Loop Statements in Chapter 4.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access