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
In reply to Re^7: Warnings not being thrown with DBI (nits)
by tye
in thread Warnings not being thrown with DBI
by hubb0r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |