in reply to Avoiding goto
for my $foo (@bar) { { cond1 ? next : action1(); cond2 ? next : action2(); cond3 ? next : action3(); } action_fallthough(); }
See perldoc on next under "Note that a block by itself is semantically identical to" or perlsyn and search for "Sorry. You can always put another block inside".
Simple example:
for (1..10) { print "$_ is an "; { next if $_ % 2; print "even "; } print "integer\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoiding goto
by ikegami (Patriarch) on Jun 11, 2010 at 00:25 UTC |