sub deepcopy{ return $_[0] unless ref $_[0]; return [ map{ deepcopy($_) } @{$_[0]} ] if ref $_[0] eq 'ARRAY'; return { map{ deepcopy($_) } %{$_[0]} } if ref $_[0] eq 'HASH'; return $_[0]; }