|go ahead... be a heretic|
Detecting an undefined hash keyby LesleyB (Friar)
|on Oct 01, 2008 at 10:26 UTC||Need Help??|
LesleyB has asked for the
wisdom of the Perl Monks concerning the following question:
I would like to either use some options to set a value or set that value according to the value in a particular file
I start off by setting the default valuemy $test = 1;
Using Getopt::Std and a my %opt; hash I then check for two single letter options, s or t with the latter superceding the former.
I then try to detect whether either of the hash values are defined.
which isn't working .. the program continues to read from file. Is this because I am using a hash and the second I mention a hash key the key exists or something else? How could I get this to work?
I also don't like the (!(defined($anyvarhere))) construct. Is there a better way to detect the non-existence of a hash key in particular and, in general terms, the undefinedness of a variable?