in reply to Re^5: Warnings not being thrown with DBI (nits)
in thread Warnings not being thrown with DBI

||= 0 is clearly an explicit assignment, not an automatic one. While I could agree with you in your earlier example, I certainly don't equate "creation through assignment" with "auto-vivification", even when dealing with references.

Replies are listed 'Best First'.
Re^7: Warnings not being thrown with DBI (nits)
by tye (Sage) on Sep 11, 2005 at 21:27 UTC

    It isn't assigning to $href->{id}, it is assigning to a magic "alias" (at a distance) which autovivifies the key and value pair. I especially consider it autovivification because the assignment creates the key even though the key is not mentioned in the assignment code. I also consider it autovivification because it is just a special (delayed) case of the following:

    To show the autovivification of a hash entry more clearly, just do \$hash{id} (using a hash entry in an lvalue 'context').

    Or, to be closer to the original code, consider

    for( $hash{id} ) { # ... } print keys %hash, $/;

    Which hasn't (yet?) been made to delay the autovivification step like was done for function arguments.

    - tye