Is this a bug in Perl (nested hash)?

C. Abney cabney at
Wed Apr 12 01:11:04 CDT 2000

On Tue, 11 Apr 2000, John R. Comeau wrote:

> Checking for the existence of a nested key like $hash{key0}{key00}
> causes $hash{key0} to exist.  Is that the way it's supposed to work?
> I would think that merely checking for the existence of
> $hash{key0}{key00} would not cause $hash{key0} to exist.

The short answer is "use exists()."  The long answer is FTCFMTE. :-)

It has something to do though, I suspect, with how autovivification is
done by perl.

perldoc perlfaq4, perldoc perlfunc

Einstein himself said that God doesn't roll dice. But he was wrong. And
in fact, anyone who has played role-playing games knows that God
probably had to roll quite a few dice to come up with a character like
Einstein.  -- Larry Wall                                     C. Abney


The posting address is: san-diego-pm-list at

List requests should be sent to: majordomo at

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at> 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> .
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