in reply to Detecting an undefined hash key
Hash keys are used as an index in the hash. Hash keys are always strings, and are always defined. There's no such thing as an undefined hash key.
Having said that:
defined is the test to use to test whether something is defined. To test the existance of a hash key, use exists.if (exists $hash{key}) { ... } # True if there's a value for 'ke +y' if (defined $hash{key}) { ... } # True if there's a value for 'ke +y' and the value is defined. if ($hash{key}) { ... } # True if there's a value for 'ke +y' and the value is true.
|
---|