in reply to adding to hashes
If you are dealing with more complicated cases then you need to do a little more work, or use a module such as Hash::Merge to do the work for you.
For example, if you have the following hash:
In the above example a simple merge of the hashes results in the following:my %a = ( k1 => 1, k2 => { kk3 => 3 }, ); my %b = ( k1 => 5, k2 => { kk4 => 4 }, ); my %c = (%a,%b);
Notice that the deep members of the hash are not merged, only the top level.%c = ( 'k1' => 5 'k2' => { 'kk4' => 4 }, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: adding to hashes
by imp (Priest) on Jul 24, 2006 at 17:50 UTC |