|
|
| We don't bite newbies here... much | |
| PerlMonks |
Re^4: Detecting an undefined hash keyby LesleyB (Friar) |
| on Oct 01, 2008 at 22:13 UTC ( [id://714911]=note: print w/replies, xml ) | Need Help?? |
|
toolic, thank you for taking the time on this. I did cut and paste your code and uncommented the usage of Data Dumper to see what was happening. Using -t, I get
with similar results for a singular -s. Observe the test to see if either option had been specified fails. Using both -s and -t I get
Using -a -b gives
and singletons of either give one hash element with the value one. So I still feel there is something strange about at least s and t as options for getopt. I read the documentation and saw that getopt and getopts appear to behave differently. It is mea culpa because the documentation clearly states getopt expects each switch to have an argument. Therefore -s -t should interpret -t as the argument to the -s switch (and vice versa). Except this doesn't appear to hold if one uses -a -b. Here the default value of 1 is used for both. I may try checking the rest of the alphabet on this one The end result is the getopts function behaves the way I originally expected getopt to behave Thank you once again for taking the time on this Update
and
-s and -t appear to be hungry in getopt
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||