First of all: You can use loop labels to controll which loop a next or last pertains to:
OUTER: foreach my $item (@array){ foreach my $subitem (@array2){ next OUTER if($subitem eq $item); } }
But to actually answer your question: I think it would be better to use grep in a scalar context to test for the presence of an item in an array (as opposed to foreach'ing through the array doing an eq comparison).
foreach my $item (@array){ next if(scalar(grep({$_ eq $item} @other_array))); }
HTH. Cheers
Update: As others have suggested, a hash is better for this type of lookup
A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you
His Holiness, The Dalai Lama
In reply to Re: in_array and skipping foreach
by JediWizard
in thread in_array and skipping foreach
by webchalkboard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |