On Tue, Jun 05, 2001 at 02:09:30PM +0200, Marcelo E. Magallon wrote:
> Perhaps also noteworthy is the fact that things like '$foo{bar} eq ""'
> make the key 'bar' spring into existance in %foo. -w tells you about
> it.
The 'bar' key doesn't spring into existence, and -w doesn't tell you about
it. You can test it with:
> perl -wle 'print "yes" if $foo{"bar"} eq ""; print "foo: ", keys(%foo);'
Use of uninitialized value in string eq at -e line 1.
yes
foo:
Autovivication (the springing into existence of keys or indices) only
happens when you're accessing a complex data structure.
For example:
print $foo{'bar'}[0]
Assuming %foo had nothing in it to begin with, the 'bar' key was created,
with an anonymous array as its value.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--