Perl 5 version 12.0 documentation
continue
- continue
continue
is actually a flow control statement rather than a function. If there is acontinue
BLOCK attached to a BLOCK (typically in awhile
orforeach
), it is always executed just before the conditional is about to be evaluated again, just like the third part of afor
loop in C. Thus it can be used to increment a loop variable, even when the loop has been continued via thenext
statement (which is similar to the Ccontinue
statement).last
,next
, orredo
may appear within acontinue
block;last
andredo
behave as if they had been executed within the main block. So willnext
, but since it will execute acontinue
block, it may be more entertaining.- while (EXPR) {
- ### redo always comes here
- do_something;
- } continue {
- ### next always comes here
- do_something_else;
- # then back the top to re-check EXPR
- }
- ### last always comes here
Omitting the
continue
section is equivalent to using an empty one, logically enough, sonext
goes directly back to check the condition at the top of the loop.If the
"switch"
feature is enabled,continue
is also a function that exits the currentwhen
(ordefault
) block and falls through to the next one. See feature and Switch statements in perlsyn for more information.