'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps.

The Camel book, page 710 in the third edition is very clear that exists goes the same way as defined. But perl has gone through a couple of new versions since it was written.

Thanks to Stewart who did get me on the right track by mentioning exists. That's where I found autovivification mentioned in the Bible.

It also says there:

"This behavior is likely to be fixed in a future release."

In 5.8.1-RC3 it hasn't changed.
I wonder if the comment refers to perl6 ? Do those fellows know about it?

I'm going to shoot myself in the foot before I check the docs, but I look at the look-ahead and look-behind perl has to take with

    if ( funxyz( $a_hash{ "D" } )

and

    if ( funxyz( $a_hash_ref{ "D" }[ $x ] )

and I think I don't want perl trying to differentiate what exists() and defined() do in any but the most simple case.

I think the English semantics of defined vs. exists is plenty to deal with, anyway.

The solution for my problem was to test just the hash element without looking at the underlying list item. Exists and defined both work that way without behaving like the Creator. Checking for the list item = "" also works if the vivifivation has occurred.

if ( defined( $a_hash_ref ) && $defined( $a_hash_ref{ "D" } ) && defined( $a_hash_ref{ "D" }[ $x ] ) )

although we usually know which of those tests we can leave out if we stop to think.

Reply via email to