for my $key (@array2){ $hash{$key}++ print "Fail $key" unless grep($key, @array1); }