sub deep_copy { my $self = shift; my $this = shift; unless (ref $this) { $this; } elsif (ref $this eq 'ARRAY') { [map $self->deep_copy($_), @$this]; } elsif (ref $this eq 'HASH') { +{map{$_ => $self->deep_copy($this->{$_})} keys %$this}; } } #### sub copy { my $self = shift; return $self->deep_copy($self); }