Is this a bug in Perl (nested hash)?

Alan Stewart astewart at spawar.navy.mil
Wed Apr 12 14:21:37 CDT 2000


~sdpm~
On 12 Apr 00, at 10:25, John R. Comeau wrote:

>    Alan> John, what did yours print? You didn't say !!
>
>Mine printed the same as yours.  I guess I was just hoping that the
>keys 'key0' and 'key1' wouldn't be created just by checking for the
>existence of the nested value.  I was thinking that only an assignment
>operation would create them.
>
>-John

If $hash{key0} didn't auto set to a reference value, you wouldn't get the free 
ride of saying $hash{key0}{key00} without first saying something like:
   $hash{$key} = {};

It just happens that there is a new module on the CPAN recent list called 
Hash-NoVivify which appears to address this problem of de-referencing inside 
exists() causing autovivify. I only took a peek at the readme.

~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list