in reply to exiting two loop levels

You need labelled loops.

OUTER: while ($something_is_true) { INNER: while ($some_other_thing_is_true) { last OUTER if $you_want_to_quit_outer_loop; last INNER if $you_want_to_quit_inner_loop; } }

See Compound statements in perldoc perlsyn for details.

Update: Added ':' to labels.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg