Perl-Sensitive Sunglasses | |
PerlMonks |
How can I have both short and long options with Getopt::Long?by Anonymous Monk |
on Nov 12, 2009 at 11:48 UTC ( [id://806698]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: I have been reading the documentation for Getopt::Long but I can't find a way to do what I would like to achive. Let's restrict it to one option only: verbose. What I would like is to be able to use -v or --verbose only. So -verbose and --verb would both be wrong. The main code is:
However, that accepts -V also. So I change it to
So far so good, but now --v or -ver both work. I thought I could use bundling like
but it doesn't quite do what I had in mind. If I use -ver it correctly says
But if I use --verb (note the double dash) it still recongnises it, which I don't want. To summarize: if there is one dash then only v is accepted and any other letter should be reported as an 'Unknown option'; if there are two dashes then only the full 'verbose' should be accepted. How can I achive that? Thanks
Back to
Seekers of Perl Wisdom
|
|