foreach( keys %hash2 ){ if( exists $hash1{$_} ){ print "$_ = ",$hash2{$_}*$hash1{$_},"\n"; } } #### my %hash = ( dog => 11, budgie => 1, #... )