in reply to Re^2: How can one change the keys of a hash to an alternative set of keys?
in thread How can one change the keys of a hash to an alternative set of keys?
... copying every field in the object by hand to the new object.
Maybe (untested):
Of course, this is still essentially "copying by hand" with lotsa potential pitfalls.use Scalar::Util qw(blessed); sub clone { my $self = shift; my $clone = blessed($self)->new or die "clone failed ($self)"; @{$clone}{keys %$self} = (values %$self); return $clone; }
Give a man a fish: <%-(-(-(-<
|
|---|