On Oct 18, Curtis Poe said: >> Friends -- Could you briefly explain the term "auto-vivification"? I have >> seen this quite a few times in some of the responses. > >Auto-vivification is trying to access a hash entry that doesn't exit. If that is >done, the hash >entry is typically created with an 'undef' value.
Incorrect. >my %hash = ( foo => 'bar', baz => 'qux' ); > >print $hash{ 'foo' }; # prints 'bar' >print $hash{ 'stuff' }; # prints nothing, but now $hash{ 'stuff' } exists and is >equal to undef No. Auto-vivification refers to the automatic generation of a reference where there was originally undef (or nothing). It is not related (or at least restricted) to hashes. Here is an example: %foo = ( this => [10,20,30], that => [40,50,60] ); print "@{[ %foo ]}\n"; # this ARRAY(...) that ARRAY(...) print $foo{this}[1]; # 20 print $foo{that}[2]; # 60 print $foo{those}[3]; # nothing print "@{[ %foo ]}\n"; # this ARRAY(...) that ARRAY(...) those ARRAY(...) Notice how using $foo{those} as a reference caused it to become an array reference (albeit an empty one)? -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]