
Chris Charley
User
Mar 10, 2013, 12:47 PM
Post #2 of 5
(156 views)
|
|
Re: [yanivr78] Quick question regarding next/last and redo
[In reply to]
|
Can't Post
|
|
the scalar is now "3" right ?, so "last if" should block it... The if checks for a value greater than 3, not equal to 3. Here is the documentation on next, last and redo.
C:\Old_Data\perlp>perldoc -f continue continue BLOCK continue "continue" is 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" 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 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, so "next" 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 falls through the current "when" or "default" block instead of iterating a dynamically enclosing "foreach" or exiting a lexically enclosing "given". See feature and "Switch statements" in perlsyn for more information.
|