On 4/4/06 Doug McNutt wrote:

>While messing with CGI POSTed data I got trapped by this one.
>
>Version 5.8.1-RC3 for Mac OS 10.3.9
>
>It appears that the hash element "D" gets defined in the process of
>testing to see if an element in the associated string is defined. The
>last if below takes the else route.
>
>Is that normal? Does it somehow make sense?
>
>%phash = (); foreach $jill ("A", "B", "C")
> { for ($lynn = 0; $lynn<3; $lynn++) { $phash{$jill}[$lynn] =
> "$jill$lynn"; print "\$phash{$jill}[$lynn] = $phash{$jill}[$lynn]\n";
>        }
>    }
>if (! defined $phash{"D"})
> { print "\$phash{D} is undefined, We expected that.\n";
>    }
>if (! defined $phash{"D"}[3])

It happened right here.

See perldoc perlref, especially "autovivification".



- Bruce

__bruce__van_allen__santa_cruz__ca__

Reply via email to