Don't ask to ask, just ask | |
PerlMonks |
Re^3: Copy of multidimensional hashby muba (Priest) |
on Jan 03, 2013 at 10:38 UTC ( [id://1011436]=note: print w/replies, xml ) | Need Help?? |
Is this the best way to create a copy of a multidimensional hash? I don't know if it's the best. At any rate, I would reformat the for loop as follows:
I find this significantly more readable than the way you formatted it. Furthermore, I would generalize copying the arrray, and tell Perl to take out all the elements instead of just those elements with index 0 and 1.
And then I would generalize it even further: take the whole array reference, dereference it in a single pass, and create and store a new reference to it. Sounds complex? Nah, not so much:
This was already suggested by johngg.</p Step by step of [ @{$one{$k}} ]:
But then I would want to generalize it even further and use Storable's dclone function, as suggested by davido.
In Section
Seekers of Perl Wisdom
|
|