sub intersection { my ( $list1, $list2 ) = @_; my %hash; @hash{@$list1} = undef; my @intersection = grep { exists $hash{$_} } @$list2; return @intersection }