Hi monks,
I basically want to compare the keys between two hashes to
see which they have in common. If they have one in common I want to
multiply the values of both keys together. I have managed to do the comparing
part, but not sure how to multiply the values. Please can anyone help?? e.g. Ideal output;
dog = 55
cat = 12
The code;
my %hash = (
'dog' => '5',
'sheep' => '10',
'cat' => '3',
);
my %hash2 = (
'dog' => '11',
'budgie' => '1',
'cat' => '4',
);
foreach (keys %hash2) {
if (exists $hash{$_}) {
print "$_ exists";
}
}