sub Intersection { my( $refA, $refB ) = @_; my %counts; ++$counts{ $1 } while $$refA =~ m[(\S+)]g; my $intersects = 0; exists $counts{ $1 } and ++$intersects while $$refB =~ m[(\S+)]g; return $intersects; }