Greetings sandrider,
In addition to using labels as two other monks have suggested already, you could use last to exit the inner loop, thus nexting to the outer loop.
foreach my $one (@one) { $one =~ m/\(.\)(.+)\(.\)/; foreach my $two (@two) { if (($1) and ($two eq $1)) { push @result, $one; last; } } }
TMTOWTDI.
Update: I moved the m// outside the inner foreach due to japhy's comment. No idea why I didn't see that before. Doh.
gryphon
Whitepages.com Development Manager (DSMS)
code('Perl') || die;
In reply to Re: using next in a nested foreach()
by gryphon
in thread using next in a nested foreach()
by sandrider
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |