Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: exiting two loop levels

by VSarkiss (Monsignor)
on Sep 21, 2006 at 14:26 UTC ( #574133=note: print w/ replies, xml ) Need Help??


in reply to exiting two loop levels

GrandFather and davorg have your answer above. I just wanted to add that it often reads better to label your loops with what they're iterating over, rather than their structure.

For example, say you're processing files and records line-by-line. You could do this:

OUTER: while ( $more ) { INNER: while ( $still_more ) { # ... last OUTER if $done_with_files; last INNER if $done_with_lines; } }
But it reads better with a change in labels:
FILE: while ( $more ) { LINE: while ( $still_more ) { # ... last FILE if $done_with_files; last LINE if $done_with_lines; } }


Comment on Re: exiting two loop levels
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-08-28 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls