in reply to multiple hash compare, find, create
I would choose the smallest of the three hashes and iterate over its keys in a loop doing an exists on the same key in the other two hashes, moving on to the next key unless existing in both of the others. If in all three, add an array ref to that key in the fourth hash. Something like:-
my %h4; foreach my $commonKey ( keys %h1 ) { next unless exists $h2{ $commonKey } && exists $h3{ $commonKey }; $h4{ $commonKey } = [ $h1{ $commonKey }, $h2{ $commonKey }, $h3{ $commonKey } ]; }
I hope this is helpful.
Cheers,
JohnGG
|
|---|