my @array_1 = qw( x y z ) ; my @array_2 = qw( v w x ) ; my %base = map { $_ => 1 } @array_1 ; my @intersection = grep { $base{$_} } @array_2 ;