in reply to use of 'continue' block for while/until
The docs are fairly self explanatory. The main use is if you have a 'next' statement in your main loop block, but you want something to happen after the 'next'. It just gives you an extra level of flow control in loops (see the docs for where each flow control statement will take you).
Trivial example (but hopefully showing basic use):
You can probably achieve the same thing with if statements, so (in this case at least) it's just syntactic suger.while ( my $foo = get_next_foo() ) { if ( $foo == 1 ) { next; } do_some_stuff(); } continue { # Everything ends up here whether 'next' was hit or not do_some_more_stuff(); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: use of 'continue' block for while/until
by GrandFather (Saint) on Jun 11, 2008 at 10:25 UTC |
In Section
Seekers of Perl Wisdom