![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
You used : where you meant to use =, but that doesn't change the result. The *option's argument* is required, not the option itself. If you want to make the option required, you can check if the option variable is defined after the call to GetOptions.
It's a bit clearer in the documentation of for ":": "If [the option's argument] is omitted, an empty string will be assigned to string values options, and the value zero to numeric options." The following would be even clearer: "If the option is present but the the option's argument is omitted, an empty string will be assigned to string values options, and the value zero to numeric options." Since the option was never specified, its argument was never omitted, so the option variable was never assigned the default value. You can assign to the option variable before calling GetOptions to get the behaviour you desire. PS — It's safer to always localize changes to global variables. local @ARGV = ...;. In reply to Re: Trying to understand subtleties of Getopt::Long, please help
by ikegami
|
|