> -----Original Message----- > From: Michael Fowler [mailto:[EMAIL PROTECTED]] > Sent: Thursday, October 04, 2001 9:37 PM > To: Curtis Poe > Cc: '[EMAIL PROTECTED]' > Subject: Re: how to tell if hash value is null vs missing > > > On Thu, Oct 04, 2001 at 04:34:17PM -0700, Curtis Poe wrote: > > --- "Collins, Joe (EDSI\\BDR)" <[EMAIL PROTECTED]> wrote: > > > $value=$myhash{$mykey}; > > > if $mykey is not a valid key, then $value still becomes "" > > > > If $mykey does not exist in the hash, then trying to access it will > > "autovivify" that hash element (with no warnings, even if > you have them > > on) and the value will be undef, not the empty string. > > That's slightly incorrect, as well. The key will not be > autovivified; if > the key doesn't exist, accessing it won't make it exist. > > So, if the key $mykey doesn't exist then $value will be > undef, and %myhash > will remain unaltered.
True, but what can happen is something like this: if ($myhash{$mykey}{a}) { ... } This *will* create $myhash{$mykey} if it didn't exist before, initializing it to a reference to an empty hash. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]