> At 04:36 PM 6/18/01 -0700, Peter Cornelius wrote:
> >use Data::Dumper;
> >
> >%hash = (
> >         1 => "I exist...",
> >         2 => "This is academic",
> >         3 => "I should be using an array"
> >         );
> >
> >print Dumper \%hash;
> >
> >for $key (keys %hash) {
> >         $hash{$key++}="Redefined";
> >         print "$key => $hash{$key}\n";
> >}
> >
> >print Dumper \%hash;
> >
> >__output__
> >$VAR1 = {
> >           '1' => 'I exist...',
> >           '2' => 'This is academic',
> >           '3' => 'I should be using an array'
> >         };
> >2 => This is academic
> >3 => I should be using an array
> >4 =>
> >$VAR1 = {
> >           '1' => 'Redefined',
> >           '2' => 'Redefined',
> >           '3' => 'Redefined'
> >         };
> >
> >---Comments--
> >So the $hash{4} never gets autovivified, even though it's 
> dereferenced,
> 
> What makes you think it's dereferenced?


The '4 => ' line up above from the print statement in the for loop.


> 
>          $hash{$key++} = $value
> 
> is equivalent to
...

> Okay?

Yeah, I think that's part of what I was saying in the above.  But also I was
trying to make sure I understood autoviv.  I had originally thought that
there was a danger of accidentaly creating a hash entry just by looking at
it, but from the above code, and a few passages in the camel, I don't think
testing a hash value will create it.  The exception to this would be
something like $hash{a}{b}, which creates 
$hash{a} if it didn't exist just to test that the b part isn't there.  I
know you know this, I knew some of it, but just was trying to get it down
solid.

Thanks again,
Peter C.

 

Reply via email to