Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Deepcopy of complex structures.

by ihb (Deacon)
on Jan 21, 2003 at 01:01 UTC ( [id://228549]=note: print w/replies, xml ) Need Help??


in reply to Deepcopy of complex structures.

What's wrong with Data::Dumper? Data::Dumper even has switches for the explicit reason of eval()ing and deep-copying.

The biggest flaw in your routine, as far as I can see, is that it doesn't handle circular references. It'll recurse to death upon

my $aref = []; $aref->[0] = $aref; deepcopy($aref);

Hope I've helped,
ihb

Replies are listed 'Best First'.
Re: Re: Deepcopy of complex structures.
by BrowserUk (Patriarch) on Jan 21, 2003 at 01:10 UTC

    My main problem with Data::Dumper--beyond the fact that it regularly blows my swap space on relatively small data structures--is that whilst the stringification/ evaling process makes sense if you need to transmit the structure between system, or store it to disk, all I want is an in-memory copy. Preferably as fast as possible, given this is a recursive routine that may be called to process large volumes of structure.


    Examine what is said, not who speaks.

    The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-24 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found