in reply to Re^2: Array compare using elements as the pattern match.
in thread Array compare using elements as the pattern match.
Alternately:
for (@array2) { for my $pat (@array1) { if (index($_,$pat) > -1) { push @a3, $_; last; } } }
For exact matches, index will be faster.
A more Perl-ish way:
for my $pat (@array1) { push @a3, grep { index($_,$pat) > -1 } @array2; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Array compare using elements as the pattern match.
by toolic (Bishop) on Dec 13, 2014 at 02:55 UTC |