OUTER_LOOP: foreach my $item qw(this that the_other) { print "$item:\n"; keys %hash; # keys resets the iterator on %hash so that our # subsequent calls to each will get all the # pairs in the hash. This is necessary in # case the iterator was left in mid-hash # by a previous loop-through that was aborted. while (my ($key, $value) = each %hash) { print " $key => $value\n"; if ($item eq 'that' && $key eq 'baz') { print "bailing out!\n"; next OUTER_LOOP; } } }