in reply to how can i return the common keys from a hash

Here are a two possible ways to find which keys appear in multiple hashes. Neither of these will report how many occurrences, or which hash they appear in - but either would be fairly easy to add.
use strict; use warnings; my %hash1 = (a => 1, b => 2); my %hash2 = (a => 1, c => 3); my %hash3 = (d => 1, c => 3); # Method 1 # Create a hash for tallying the number of times keys occur in the oth +er hashes. my %key_bucket = (); for my $key (keys %hash1, keys %hash2, keys %hash3) { $key_bucket{$key}++; } my @duplicates = grep {$key_bucket{$_} > 1} keys %key_bucket; print "Method 1:\n"; print "$_\n" for @duplicates; # Method 2 # Create a list of unique keys, then check how many hashes each key ap +pears in print "Method 2:\n"; my %unique = map {$_ => 1} keys %hash1, keys %hash2, keys %hash3; for my $key (keys %unique) { my (@matches) = grep {exists $_->{$key}} \%hash1, \%hash2, \%hash3 +; print "$key\n" if @matches > 1; }