Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: exists on hash autovivifies right?

by pc88mxer (Vicar)
on Jun 28, 2008 at 23:24 UTC ( [id://694553]=note: print w/replies, xml ) Need Help??


in reply to Re: exists on hash autovivifies right?
in thread exists on hash autovivifies right?

If you need to test for existence without autovivification, you'll have to code up a test that goes something like this:
sub my_exists { my $struct = shift; while (@_) { my $key = shift(@_); return false unless exists $hash->{$key}; $hash = $hash->{$key}; } 1; } my $x = {}; if (my_exists($x, 'a', 'c')) { print "c exists\n"; } else { print "c doesn't exist\n"; } print Dumper($x);

Replies are listed 'Best First'.
Re^3: exists on hash autovivifies right?
by lodin (Hermit) on Jun 29, 2008 at 09:55 UTC
      nice modu;es. thanks.
Re^3: exists on hash autovivifies right?
by Anonymous Monk on Jun 29, 2008 at 21:03 UTC
    nice solution. thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://694553]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-25 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found