JAMBOID has asked for the wisdom of the Perl Monks concerning the following question:
my $arrayObjsRef = \@arrayOfObjects; my $copy = _deep_copy( $arrayObjsRef ); sub _deep_copy { my $this = shift; my $ref = ref $this; if ( not ref $this ) { $this; } elsif ( ref $this eq "ARRAY" ) { [ map _deep_copy( $_ ), @$this ]; } else { # this is where the objects would be copied +{ map { $_ => _deep_copy( $this->{$_} ) } keys %$this }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: deep_copy objects question
by GreyGlass (Sexton) on Aug 13, 2004 at 19:57 UTC | |
by merlyn (Sage) on Aug 13, 2004 at 20:54 UTC | |
by JAMBOID (Sexton) on Aug 13, 2004 at 20:16 UTC | |
|
Re: deep_copy objects question
by dragonchild (Archbishop) on Aug 13, 2004 at 19:24 UTC | |
|
Re: deep_copy objects question
by Fletch (Bishop) on Aug 13, 2004 at 19:34 UTC | |
|
Re: deep_copy objects question
by ihb (Deacon) on Aug 13, 2004 at 22:27 UTC | |
|
Re: deep_copy objects question
by johnnywang (Priest) on Aug 13, 2004 at 19:44 UTC |