my %hash1; @hash1{@array1} = (); my @intersection = grep {exists $hash1{$_} } @array2;