in reply to Re: Making a failed hash lookup return something other than undef
in thread Making a failed hash lookup return something other than undef
Actually, auto-vivification of hash entries doesn't happen unless you do something like take a reference to the hash entry... for example by referring to something more deeply nested in the non-existent hash entry:
#!/usr/bin/perl -l my %hash; my $foo = $hash{'foo'}; print exists $hash{'foo'} ? "yes" : "no"; # prints "no" my $bar = $hash{'bar'}->{'xxx'}; print exists $hash{'bar'} ? "yes" : "no"; # prints "yes" my $baz = \$hash{'baz'}; print exists $hash{'baz'} ? "yes" : "no"; # prints "yes"
-- Mike
--
XML::Simpler does not require XML::Parser or a SAX parser.
It does require File::Slurp.
-- grantm, perldoc XML::Simpler
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Making a failed hash lookup return something other than undef
by shenme (Priest) on Nov 13, 2003 at 20:33 UTC |