Do you know where your variables are? | |
PerlMonks |
undef vs 0by skx (Parson) |
on Feb 06, 2003 at 09:38 UTC ( [id://233093]=perlquestion: print w/replies, xml ) | Need Help?? |
skx has asked for the wisdom of the Perl Monks concerning the following question: Hello Monks, I've got a simple problem with a configuration file parser/settings object. I've written a simple module which allows access to configuration values, and I find that I'm not able to differentiate between a value that is unset, and a value that is zero easily. Consider the following:
What I want to do is to say read the value, and if it's not defined use '1' as a default. What actually happens is that if the value is set to '0' it gets ignored. I see the following as a solution:
but that seems a little messy. Short of re-writing the code to be 'getConfigValue( "keyname", "default" )' which would be a pain is there a simple solution? Steve--- steve.org.uk
Back to
Seekers of Perl Wisdom
|
|