Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a 4 level data structure : ref to a hash of hash of list of hashes . I can't figure how to clone . Would appreciate any help

Replies are listed 'Best First'.
Re: how to clone
by uwevoelker (Pilgrim) on Feb 12, 2002 at 17:51 UTC
    There is a module Clone.
    use Clone qw(clone); $a = { 'foo' => 'bar', 'move' => 'zig' }; $b = [ 'alpha', 'beta', 'gamma', 'vlissides' ]; $c = new Foo(); $d = clone($a); $e = clone($b); $f = clone($c);
Re: how to clone
by buckaduck (Chaplain) on Feb 12, 2002 at 17:51 UTC
    perlfaq4: How do I print out or copy a recursive data structure?

    Click the link and find out...

    buckaduck

Re: how to clone
by jackdied (Monk) on Feb 13, 2002 at 05:22 UTC
    Use the above suggestions if you want a deep copy. If you only want a shallow copy (just the top level elements) then try this (assumes a blessed hash object)
    my %cp = %$original_object; my $cloned_object = bless(\%cp, ref($original_object));
    -jackdied