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 other 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 appears 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; }