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 reply to Re: deep copy of hash of hash
by haukex
in thread deep copy of hash of hash
by cmic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |