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:
But it reads better with a change in labels:OUTER: while ( $more ) { INNER: while ( $still_more ) { # ... last OUTER if $done_with_files; last INNER if $done_with_lines; } }
FILE: while ( $more ) { LINE: while ( $still_more ) { # ... last FILE if $done_with_files; last LINE if $done_with_lines; } }
In Section
Seekers of Perl Wisdom