We don't bite newbies here... much | |
PerlMonks |
Re: What could be the exact usage of While - continue loopby naikonta (Curate) |
on May 09, 2007 at 04:18 UTC ( [id://614293]=note: print w/replies, xml ) | Need Help?? |
The continue block is guaranteed to be executed in each iteration.
See that the i line is not always printed because it depends on if checking, while j line is always printed regardless what happens inside the while block*. This won't happen if printing j line is put inside the block as i. But frankly, I never use continue myself in practical. It exists for some reason regarding the for loop (see Programming Perl). From the doc: "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.Some monk commented on that emphasized text but I can't recall the node. * Unless redo take place, as shown by GrandFather below. The same thing with last. Consider,
Update: added note following correction by GrandFather Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
In Section
Seekers of Perl Wisdom
|
|