my %hash; $hash{$_}=1 foreach @array_1; @array_2=grep($hash{$_},@array_2); #### #for (my $search =0; $search