http://qs321.pair.com?node_id=484040


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;