in reply to exists on hash autovivifies right?
No. exists would always return true if it autovivified the element being tested. It will however autovivify any elements the element being tested depends on. Consider:
use strict; use warnings; my %hash; if (exists $hash{top}{dependent}) { print "\$hash{top}{dependent} exists\n"; } else { print "\$hash{top}{dependent} does not exist\n"; } if (exists $hash{top}) { print "\$hash{top} exists\n"; } else { print "\$hash{top} does not exist\n"; }
Prints:
$hash{top}{dependent} does not exist $hash{top} exists
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: exists on hash autovivifies right?
by Anonymous Monk on Jun 28, 2008 at 23:32 UTC | |
by GrandFather (Saint) on Jun 28, 2008 at 23:41 UTC | |
by Anonymous Monk on Jun 29, 2008 at 20:54 UTC |