sub deepcopy{ my $this = shift; if (not ref $this){ $this; } elsif (ref $this eq "ARRAY") { [map deepcopy($_), @$this]; } elsif (ref $this eq "HASH"){ scalar { map { $_ => deepcopy($this->{$_}) } keys %$this }; } else { die "what type is $_?"} }