Clear questions and runnable code
get the best and fastest answer
Wisdom on the Getopt::Long moduleby abhijithtk (Novice)
|on Jul 14, 2010 at 18:11 UTC||Need Help??|
abhijithtk has asked for the
wisdom of the Perl Monks concerning the following question:
My question might be a bit stupid but it would be nice if i could get it to work.
I have a command line option, say -x. In the GetOptions() function i have declared it as GetOptions('x:s'=>\$x);
Incase the -x option is given with a string, $x gets that value.
Incase the -x option is given with no string , $x becomes 0.
Is there anyway for me to acheive both, handle the case where if some value is passed $x contains that string and if no value is passed, $x remains true. ie not 0.
It is a stupid question, but i want to be able to use the same variable, to do differnt things.
Is this even possible? :O