Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: deep copy of nested data structure

by autark (Friar)
on Nov 22, 2000 at 13:54 UTC ( #42892=note: print w/replies, xml ) Need Help??


in reply to deep copy of nested data structure

For cloning purposes, may I suggest using either the Storable modules dclone method
use Storable qw(dclone); my $copy = dclone($some_ref);
or perhaps the Clone module
use Clone qw(clone); my $copy = clone($some_ref);
Back to your problem at hand, the reason you get 1 as a result of the thaw method, is because it is documented to return an array. And an array in scalar context returns the number of elements, which in your case is 1. Try something like this: @copy = thaw freeze $hashref Autark.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://42892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2020-12-06 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?