in reply to memory use when merging tied hashrefs
It might depend on which version of perl you are using, but one way to avoid using a temporary list (%$hash1, %$hash2 is flattened to a list of pairs before being added to the anonymous hash) you can iterate over the hashes using each.
Same for $hash2. This also depends on how the tied hash is implemented but it's worth a try...while (my ($key, $value) = each %$hash1) { $hash3{$key} = $value; }
Edit: or you could also tie hash3 to fetch data either from hash1 or hash2 ... really depends on what you are trying to achieve and what are your contraints.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: memory use when merging tied hashrefs
by Anonymous Monk on Nov 13, 2019 at 14:50 UTC | |
by Eily (Monsignor) on Nov 13, 2019 at 17:18 UTC | |
by Eily (Monsignor) on Nov 13, 2019 at 15:56 UTC | |
by Anonymous Monk on Nov 13, 2019 at 20:22 UTC |