Pitonyak::DeepCopy - Copy an object with new copies, even if it contains references.
use Pitonyak::DeepCopy;
my $new_hash_ref = Pitonyak::DeepCopy::deep_copy(\%original_hash);
I ran into problems when I had a hash that contained another hash reference. I copied the elements from one hash to another and then changed the values in the referenced hash. Confused? Okay, here is what the code looked like.
my %old_hash = ('val' => 2, 'ref' => {'E' => 1}, );
I then made a new hash with all the same values in %hash_ref
but this included a reference
to the hash because my code included $new_hash{'ref'} = $old_hash.{'ref'};
I then created this method so now I can do:
my $hash_ref = Pitonyak::DeepCopy::deep_copy(\%pld_hash);
Copyright 2002, Andrew Pitonyak (perlboy@pitonyak.org)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Version 1.00 First release
Copyright 1998-2002, Andrew Pitonyak (perlboy@pitonyak.org)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Version 1.00 First release
Version 1.01 Changed internal documentation to POD documentation. Added parameter checking.