in reply to Re: exists on hash autovivifies right?
in thread exists on hash autovivifies right?
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 | |
by Anonymous Monk on Jun 29, 2008 at 21:05 UTC | |
|
Re^3: exists on hash autovivifies right?
by Anonymous Monk on Jun 29, 2008 at 21:03 UTC |