Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw


by gods
on Aug 24, 1999 at 22:42 UTC ( #276=perlfunc: print w/ replies, xml ) Need Help??


See the current Perl documentation for continue.

Here is our local, out-dated (pre-5.6) version:

continue - optional trailing block in a while or foreach

continue BLOCK

Actually a flow control statement rather than a function. If there is a continue BLOCK attached to a BLOCK (typically in a while or foreach), it is always executed just before the conditional is about to be evaluated again, just like the third part of a for loop in C. Thus it can be used to increment a loop variable, even when the loop has been continued via the next statement (which is similar to the C continue statement).

last, next, or redo may appear within a continue block. last and redo will behave as if they had been executed within the main block. So will next, but since it will execute a continue block, it may be more entertaining.

    while (EXPR) {
        ### redo always comes here
    } continue {
        ### next always comes here
        # then back the top to re-check EXPR
    ### last always comes here

Omitting the continue section is semantically equivalent to using an empty one, logically enough. In that case, next goes directly back to check the condition at the top of the loop.

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2015-10-06 17:51 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (156 votes), past polls