my %hash = (
'foo' => 1,
'bar' => 2,
'baz' => 3,
);
OUTER_LOOP: foreach my $item qw(this that the_other)
{
print "$item:\n";
# keys %hash; # this resets the iterator
while (my ($key, $value) = each %hash)
{
print " $key => $value\n";
if ($item eq 'that' && $key eq 'baz')
{
print "bailing out!\n";
next OUTER_LOOP;
}
}
}
####
this:
foo => 1
baz => 3
bar => 2
that:
foo => 1
baz => 3
bailing out!
the_other:
bar => 2
####
this:
foo => 1
baz => 3
bar => 2
that:
foo => 1
baz => 3
bailing out!
the_other:
foo => 1
baz => 3
bar => 2