On Mon, Jun 20, 2005 at 07:02:38AM -0700, Will Lowe wrote:
> > Only this isn't ever going to work because there's no way in pure perl that
> > you can create such a structure - what it writes doesn't work because
> > $VAR1 doesn't have a value at the point of assignment, and even if it wrote
> > the fixup after the initial creation of $VAR1 as:
> > 
> >     $VAR1->{'4'} = ${\$VAR1->{'3'}};
> > 
> > because the hash assignment does a copy, not a binding.
> 
> But if I do this in Perl:
> 
> $VAR1->{3} = undef;
> $VAR1->{4} = undef;
> 
> Data::Dumper understands it just fine.  Aren't the values aren't both
> set to PL_sv_undef (and if so why doesn't it confuse Data::Dumper)?
>
> Or does Perl make a copy of PL_sv_undef and set the values to the
> copies?  I thought the point of the global variables was to avoid
> making copies in situations like this ...

The latter.
Assignments to hash values are always copies.

Nicholas Clark

Reply via email to