http://www.perlmonks.org?node_id=948460


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.