in reply to Re: Merging references
in thread Merging references

Or you could use a slice instead of the inner loop. The following piece is a rewrite, that is easily extended to more than merging the result of two subs:
my $part1 = Sub1(); my $part2 = Sub2(); my $ans = {}; # where the final answer will live foreach my $part ($part1, $part2) { # loop over parts foreach my $k (keys %$part) { my $inner = $part->{$k}; @{$ans->{$k}}{keys %$inner} = values %$inner; } } use Data::Dump qw(dump); print dump $ans; # that's what you got

Obviously, this merge only works at two-level hashes.