my @a = ( 'a1', 'b2', 'c3', 'd4' ); my @b = ( '3', '4', '5', '6' ); my @results; foreach my $num (@b) { push @results, grep { /$num/ } @a; } # @results will contain 'c3' and 'd4'
Update - Erk, modified answer to address the question at hand - If in fact you do simply need to find the union of two arrays, this node should help you out :-)
In reply to Re: comparing element in arrays
by rob_au
in thread comparing element in arrays
by smoss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |