Keep It Simple, Stupid | |
PerlMonks |
Re: deep copy of hash of hashby haukex (Archbishop) |
on May 24, 2019 at 16:57 UTC ( [id://11100476]=note: print w/replies, xml ) | Need Help?? |
my $y = {%x}; Although this does create a reference to a new anonymous hash and copies the key/value pairs (you can modify the keys of %$y without affecting the set of keys in %x), this is still not a deep copy - the values are still references to the same nested hashes ({'lastname' => 'michael','tel'=>'222'}) as in the original data structure. For true deep copies, see e.g. dclone from Storable or Clone. Minor improvements to wording.
In Section
Seekers of Perl Wisdom
|
|