use Getopt::Long; GetOptions( "ot:s" => \$ot ) or die("Error in command line arguments\n +");
The problem occurs when -ot (without a value) is followed by either another option or a program argument. The -ot option will take the next word as its value.
I know I can signal the end of options by using -- on the command line, but for backward compatibility before this program used Getopt::Long (the program previously used "/usr/bin/perl -s" to process command line options), I would like to tell Getopt::Long to always require an equals sign before a value so that -ot (without a value) can be followed by a program argument without the invervening -- in the command line.
Here is what I am aiming for:
Scenario #1:
myprog.pl -ot=123 arg1 arg2 ...
This works fine. Variable $ot='123'
Scenario #2:
myprog.pl -ot arg1 arg2 ...
I need $ot to be set to the empty string '' instead of 'arg1', without the need of an intervening -- on the command line (hence the need to force Getopt::Long to require an equals sign between the option name and its value).
Again, my goal is backward compatibility with the way this program was called before adding Getopt::Long, because this program is very central to the system and is literally called in thousands of places. TIA for any suggestions.
"It's not how hard you work, it's how much you get done."
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |