I don't know if this is the fastest way, but I've used this before and it doesn't seem to be too slow. It will use a bit of memory though, as you end up with a hash that has a union of the keys off all the hashes.
# untested, supports the interface you describe
sub commonkeys {
my $number_of_hashes = scalar(@_);
my %union;
my @result;
foreach (@_) {
foreach (keys %{$_}) {
$union{$_}++;
}
}
while (my ($key,$count) = each %union) {
if ($count == $number_of_hashes) {
# a key which has appeared the same number of
+times as we have hashes, is present in every hash.
push(@result,$key);
}
}
return @result;
}
Odds are if you do a super search or look in Q/A, somebody else has had to do this too.
HTH
/\/\averick
perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"