in reply to Generate union of the two hashes
The reason you are clobbering your initial hash is because your structure is a hash of hashes, so while they are different at the base level, you have the same object (a hash reference) associated with the key drug comparison. To make a shallow copy, I usually use Data::Dumper again, this time in an eval in a do:
I would suggest making the copy in your union_of_h1_h2 sub.my $h1 = { 'drug comparison' => { '7003000.xml' => { 'entity' => 'a1, a2, a3' }, '70037559.xml' => { 'entity' => 'x1, x2, x3' } } }; my $copy = do{my $VAR1; eval Dumper $h1; $VAR1;};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Generate union of the two hashes
by shan_emails (Beadle) on Sep 08, 2010 at 15:19 UTC |