in reply to Compare Lists (Non Unique Intersection)

I am not an expert on List::Compare, but my instinct would be that it doesn't handle your requirement. My spotty mathematics background associates the word "intersection" with "set theory". And sets (unlike lists) consist by definition of unique elements.

That being said, it would be possible to roll your own "non-unique" intersection using loops, like so*:

my @results = nonunique_intersect(\@temp, \@temp2); # ... sub nonunique_intersect{ my ($a1, $a2) = @_; my @unused_list = @$a2; my @results = (); for (@$a1){ # For each element in the first array... for (my $i = 0; $i < @unused_list; $i++){ # Search for it in # the 2nd array... if ($unused_list[$i] eq $_){ # if found, add to results, # remove from unused list. push @results, splice @unused_list, $i, 1, (@unused_list[$i+1 .. $#unused_list]); last; } } } return @results; }
YMMV.

*Tested only with your example sets!