Hello,
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.
for eg
perl someprogram.pl -x "hello" // $x becomes "hello"
perl someprogram.pl -x // $x becomes 0, but i want it to be set to true, since the option wa +s entered on command line.
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
Thanks!
20100721 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
In reply to Wisdom on the Getopt::Long module by abhijithtk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |