my %common; $common{$_}++ for keys(%hash1), keys(%hash2); my @common = grep { $common{$_} > 1 } keys %common;