my %count; $count{$_}++ for @temp; my @non_unique_intersection = grep { $count{$_}-->0 } @temp2;