harpreetsammi has asked for the wisdom of the Perl Monks concerning the following question:
Hi Experts,
I am running a perl script which uses GetOpt::Long
giveinfo.pl -name mike -long
where, -name option ("name=s") needs a mandatory string argument
-long is optional flag if set, will provide more details of the user named mike
If i miss the user name while running giveinfo.pl as below then it does not error out -
giveinfo.pl -name -longIn this case, its treating -long as user name and DOES NOT error out. I want that in above case it should error out and say "Option name requires an argument".
FYI. in the below scenario it error out as expected if i use -name at the end of command line -
giveinfo.pl -long -name Option name requires an argument
Can someone please help how can i error out correctly in the below scenerio which is missing name mike -
giveinfo.pl -name -longI don't want to use "=" as -
giveinfo.pl -name= -long
Thanks and Regards,
Harry
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long treating option as an argument
by Athanasius (Archbishop) on Dec 16, 2014 at 16:12 UTC | |
by pme (Monsignor) on Dec 16, 2014 at 16:46 UTC | |
|
Re: getopt::long treating option as an argument
by toolic (Bishop) on Dec 16, 2014 at 16:52 UTC |