my %hash1 = (a=>4,b=>5,c=>6,d=>7); my %hash2 = (a=>4,b=>5,c=>6,e=>7); # make a temp. copy of the keys of %hash1 my %h1k = map {$_=>1} keys %hash1; # delete from it all the keys present in %hash2 delete @h1k{keys %hash2}; # you're left with the keys that are only in %hash1 print "hash1 only: $_\n" for keys %h1k; # and vice versa for %hash2: my %h2k = map {$_=>1} keys %hash2; delete @h2k{keys %hash1}; print "hash2 only: $_\n" for keys %h2k; __END__ hash1 only: d hash2 only: e