in reply to Why does testing a key create a hash?
perldoc -f exists exists EXPR Given an expression that specifies a hash element or array element, returns true if the specified element in the hash or array has ever been initialized, even if the corresponding value is undefined. The element is not autovivified if it doesn't exist. print "Exists\n" if exists $hash{$key}; print "Defined\n" if defined $hash{$key}; print "True\n" if $hash{$key}; print "Exists\n" if exists $array[$index]; print "Defined\n" if defined $array[$index]; print "True\n" if $array[$index]; A hash or array element can be true only if it's defined, and defined if it exists, but the reverse doesn't necessarily hold true. ....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does testing a key create a hash?
by friedo (Prior) on Aug 17, 2005 at 22:39 UTC |