#{ # print "$_\n" for grep {$_} @a{keys %b}; #} # # should be something like (untested..) foreach my $bkey (keys %b) { warn "key not defined" unless $bkey; ## what is the purpose of your "grep {$_}"??? if ($a{$bkey}){print "FOUND: [$bkey] in the hash \%a\n"} else{print "NOT found key [$bkey] in the hash \%a\n"} }