in reply to using next in a nested foreach()
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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: using next in a nested foreach()
by Codon (Friar) on Aug 16, 2005 at 17:56 UTC |
In Section
Seekers of Perl Wisdom