You probably want something like this: use a hash to record all the items in the first array, then grep for items in the second array that you haven't already seen:
my %seen_in_1; $seen_in_1{$_}++ for @rray1; my @in_2_but_not_1 = grep { not $seen_in_1{$_} } @rray2;
Or, to avoid duplicates:
my %seen_in_1; $seen_in_1{$_}++ for @rray1; my $seen_in_2_but_not_1; $seen_in_2_but_not_1{$_}++ for grep { not $seen_in_1{$_} } @rray2; my @in_2_but_not_1 = keys %seen_in_2_but_not_1;
In reply to Re: Match string in array
by polypompholyx
in thread Match string in array
by nimdokk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |