in reply to How best to replicate/copy a hash of hashes
#!/usr/bin/perl my %hash= ( 'a' => [ 1=>2, 3=>4 ], 'b' => [ 5=>6, 7=>8 ] ); print \%hash," ", $hash{'a'}," ", $hash{'b'},"\n"; my %hash2= %hash; print \%hash2," ", $hash2{'a'}," ", $hash2{'b'},"\n"; #prints HASH(0x8daf70) ARRAY(0x8aee28) ARRAY(0x8cfc10) HASH(0x8db120) ARRAY(0x8aee28) ARRAY(0x8cfc10)
As you can see, %hash2 is at a different memory location but the entries in the hash point to the same subhashes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How best to replicate/copy a hash of hashes
by flexvault (Monsignor) on Oct 04, 2010 at 19:08 UTC | |
by jethro (Monsignor) on Oct 05, 2010 at 00:13 UTC | |
by flexvault (Monsignor) on Oct 05, 2010 at 11:06 UTC | |
by Marshall (Canon) on Oct 05, 2010 at 05:42 UTC | |
by flexvault (Monsignor) on Oct 05, 2010 at 11:48 UTC | |
by Marshall (Canon) on Oct 05, 2010 at 15:48 UTC |