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);
In reply to Re^2: exists on hash autovivifies right?
by pc88mxer
in thread exists on hash autovivifies right?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |