Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Keyword last for loops

by TomDLux (Vicar)
on Jan 18, 2012 at 02:19 UTC ( #948460=note: print w/ replies, xml ) Need Help??


in reply to Keyword last for loops

'last' and 'next' always break the innermost loop, so it's perfectly clear.

But it's a lot clearer to read if you use labels ( traditionally ALLCAPS ).

LINE: while ( my $line = <$datafile> ) { my @fields = split ',', $line; FIELD: for my $field ( @fields ) { if ( foo() ) { next FIELD; } elsif ( bar() ) { next LINE; } else { more(); } } }

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


Comment on Re: Keyword last for loops
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948460]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2015-07-05 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls