Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: improve ugly flow control

by Aristotle (Chancellor)
on Sep 19, 2004 at 07:11 UTC ( #392126=note: print w/replies, xml ) Need Help??


in reply to improve ugly flow control

The obvious answer is, of course, a labelled block.

TRY: { foreach my $try ( @options ) { next unless exists $hash{ $try }; do_something( $try ); last TRY; } log_failure(); }

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: improve ugly flow control (goto considered useful)
by Pragma (Scribe) on Sep 19, 2004 at 10:53 UTC
    This would have been obvious 30 years ago; perhaps less so today:
    foreach my $try (@options) { next unless exists $hash{$try}; do_something($try); goto SUCCESS; } log_failure(); SUCCESS: ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://392126]
help
Chatterbox?
[LanX]: ]t
[LanX]: am I the only one who first thinks scifi when a post starts with "Solaris"?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-03-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (294 votes). Check out past polls.