and what happens when the number of elements increases? This code is O(n2) which doesn't scale at all well. Better is something like:
my %hits; ++$hits{$_} for @a1; my @matched = grep {exists $hits{$_}} @a2;
In reply to Re^2: Array comparison using perl
by GrandFather
in thread Array comparison using perl
by ajguitarmaniac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |