Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Inconsistent behavior of Getopt::Stdby likbez (Sexton) |
on Aug 16, 2020 at 05:42 UTC ( [id://11120805]=perlquestion: print w/replies, xml ) | Need Help?? |
likbez has asked for the wisdom of the Perl Monks concerning the following question:
Who can propose modification to Getopt::Std which fixes the following behavior: in case you do not supply a value to the option which expect values (like "b:" below), the behavior of this module varies depending on if the parameter is the last in the line or not. If it is not the last, then the next option or argument is "eaten" as the value. Which is clearly undesirable. BTW it eats "final options separator"('--') with the same appetite as the other options.
NOTE: During testing I discovered that this module correctly processes setting the value of an option via repetition of the option letter , like -ddd. Here is the test program that I used: In short test run with parameters -b -ddd produces non-intuitive result, where -ddd is eaten by -b and becomes the value of option -b. Please note that is the next option is option without parameter, like "-b -c -ddd", then the option -c will be simply not set (it will become the value of -b), but option -ddd will be processed correctly, so such error will probably will not be detected :-) But if the parameter without the value is the last, like in: the result is as expected: options('b') is set to zero length string. Here are my test runs:
The main loop in this module is just 60 lines of rather compact and terse Perl. I hope that one of Perl guru here can easily find elegant solution to this problem:
Thank you in advance for any help. 2020-08-16 Athanasius changed <pre> to <c> tags.
Back to
Seekers of Perl Wisdom
|
|