in reply to Re^2: What is the easiest way to merge two hashes?
in thread What is the easiest way to merge two hashes?
Yes, it does. But why did you not try yourself????
use strict; use warnings; use Data::Dumper; my $ref1= { ref1_specific_key => 'some value', common_key => { common_subkey => 'foo' } }; my $ref2= { ref2_specific_key => 'some other value', common_key => { common_subkey => 'bar' } }; my $output = { %$ref1, %$ref2 }; print Dumper $output;
Of course, in a more complex example it might not work as expected. But the example you show works ok.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: What is the easiest way to merge two hashes?
by tkguifan (Scribe) on Feb 15, 2015 at 08:45 UTC | |
by hdb (Monsignor) on Feb 15, 2015 at 09:05 UTC | |
by hdb (Monsignor) on Feb 15, 2015 at 08:50 UTC | |
by tkguifan (Scribe) on Feb 15, 2015 at 08:57 UTC |