for my $key (@array1) { print "Fail: array1 element is $key, array2 element is $hash{$key}\n" unless $hash{$key}; }