The three CPAN modules suitable for copying data structures are:
Storable, Data::Dumper and FreezeThaw. Of these, Storable offers the dclone method which addresses the
problem on hand.
use Storable qw(dclone); $ref2 = dclone ($ref1);
The method works on references to scalars, arrays and hashes.
alfred,
Bakken, Luke wrote:
Hello List, To explain the problem I am having, I wrote a simple snipet that doesn't do anything meaningful other than illustrating the behaviour I want to avoid:
my %hoh = ( 1 => { a => 5, b => 5 },
2 => 5 );
my @res = &RANDOMSUB; #call a random subroutine
print "$hoh{1}{a} $hoh{2} \n";
sub RANDOMSUB { my %hohcopy = %hoh;
$hohcopy{1}{a} = 2;
$hohcopy{2} = 2;
}
Search for "clone" on search.cpan.org
-- Alfred Vahau IT Services - University of Papua New Guinea PO Box 320 - University PO - NCD 134 Papua New Guinea Ph. (675) 3267277 - Fax. (675) 3267187 - Mobile: (675) 6888926 email: [EMAIL PROTECTED]