in reply to Code requested for array intersection count
As you don't care how many times the items are in array 1, I'd use a hash rather than multiple greps. A hash will make it an O(M + N) algorithm, the greps are an O(M x N) solution. Of course, this will use more memory too and you should take that into consideration when choosing which to use.
my %seen; @seen{@array_1} = (0) x @array_1; exists( $seen{$_} ) and $seen{$_}++ for @array_2;
-sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom