Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Trying to understand subtleties of Getopt::Long, please help

by Sidhekin (Priest)
on Sep 23, 2007 at 22:22 UTC ( #640619=note: print w/replies, xml ) Need Help??


in reply to Trying to understand subtleties of Getopt::Long, please help

What is "mandatory" and "optional" is not the option itself (options are by their nature always optional) but rather the associated argument.

That is, --option without an argument will be an error on option=s or option=i, but will give the empty string on option:s and zero on option:i.

(A missing --option or an option with argument (--option=42) will be treated the same by both.)

Try @ARGV = qw( --tag ); with your cases 5 and 6, and you'll see the behaviour you expected.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://640619]
help
Chatterbox?
[ambrus]: holli: wait, plastic or glass bottle?
holli switches OS
[holli]: Lidl only sells plastic
[Corion]: holli: Oooh, a twister top - so yes, that's a worse state of mind than it sounded ;)
[holli]: and since I outed myself anyway as a horrible person, to top it off, the bottle contains beer. alcohol free beer
[Discipulus]: nowaday such beers have also a good taste
[Corion]: holli: Heh - if you consider alcohol free beer as a not-so-sweet lemonade, you're not that bad off ;)
[holli]: actually, that's exactly how i look at it.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2017-09-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?