in reply to How to copy a referenced data structure?

I don't think there's a way to avoid recursing to make the copy. Assuming the referenced data structure has refs within refs anyway.

Might I suggest Storable's freeze/thaw combo: dclone()? It handle's most of the surprises automatically.

Say you have $ar = [ 1,2,3 ];. You can in fact copy it with $b = [ @$ar ]. It doesn't work quite right with $ar = [ [ 1,2,3 ] ] however, as you'll end up with a copy of the ref in a new array ref, if you follow my meaning.

-Paul

Replies are listed 'Best First'.
Re^2: How to copy a referenced data structure?
by Anonymous Monk on May 18, 2007 at 18:18 UTC
    Wow, I feel like a fool. I was so focused on the top reference, i forgot the nested structures were also refs...

    I used Storable as you suggested, and it works great. Thanks!