jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:
I have a for loop nested within a hash loop. If the push to @groups is performed I want the for loop to exit and the hash loop to move onto the next key. I think I should be using next, but where to put it?
while ( my ($key, $value) = each %ids ) { for my $item (@names) { if ($item =~ /$key/) { push @groups, $item; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested loops and next
by GrandFather (Saint) on Sep 03, 2014 at 20:58 UTC | |
|
Re: nested loops and next
by AppleFritter (Vicar) on Sep 03, 2014 at 20:25 UTC | |
|
Re: nested loops and next
by jonnyfolk (Vicar) on Sep 03, 2014 at 20:35 UTC | |
by AppleFritter (Vicar) on Sep 03, 2014 at 21:01 UTC |