Similar results on 5.12.0. On Wed Jul 04 06:11:31 2001, merlyn@stonehenge.com wrote: > use Data::Dumper; > my @dogs = ( 'Fido', 'Wags' ); > my %kennel = ( > First => \$dogs[0], > Second => \$dogs[1], > ); > $dogs[2] = \%kennel; > my $mutts = \%kennel; > > print "CORRECT:\n"; > print Data::Dumper->new( > [\@dogs, \%kennel, $mutts], > [qw($dogs $kennel $mutts)])->Purity(1)->Dump; > > print "WRONG:\n"; > print Data::Dumper->new( > [\%kennel, \@dogs, $mutts], > [qw($kennel $dogs $mutts)])->Purity(1)->Dump; > > Output: > > CORRECT: > $dogs = [ > 'Fido', > 'Wags', > { > 'First' => '', > 'Second' => '' > } > ]; > $dogs->[2]{'First'} = \$dogs->[0]; > $dogs->[2]{'Second'} = \$dogs->[1]; > $kennel = $dogs->[2]; > $mutts = $dogs->[2]; > WRONG: > $kennel = { > 'First' => \'Fido', > 'Second' => \'Wags' > }; > $dogs = [ > ${$kennel->{'First'}}, > ${$kennel->{'Second'}}, > {} > ]; > $dogs->[2] = $kennel; > $mutts = $kennel; > > The WRONG is wrong because the $dogs->[0] is set to a separate copy of > the 'Fido' string, and no longer is associated with $kennel->{First}. > Ditto for 'Wags'. > > I'm not sure how to fix this... you really need to dump $dogs before > $kennel here so you can take a reference to the array element in > place. Or it has to be patched up afterward. I'm turning Purity on, > which is usually pretty good about constructing the patchups. But it > wasn't sufficient here. -- Alexandr Ciornii, http://chorny.netThread Previous