- continue
continueis actually a flow control statement rather than a function. If there is acontinueBLOCK attached to a BLOCK (typically in awhileorforeach), it is always executed just before the conditional is about to be evaluated again, just like the third part of aforloop in C. Thus it can be used to increment a loop variable, even when the loop has been continued via thenextstatement (which is similar to the Ccontinuestatement).last,next, orredomay appear within acontinueblock.lastandredowill behave as if they had been executed within the main block. So willnext, but since it will execute acontinueblock, 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
continuesection is semantically equivalent to using an empty one, logically enough. In that case,nextgoes directly back to check the condition at the top of the loop.If the "switch" feature is enabled,
continueis also a function that will break out of the currentwhenordefaultblock, and fall through to the next case. See feature and "Switch statements" in perlsyn for more information.

