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:
use Getopt::Long; my $verbose=''; GetOptions ( 'verbose' => \$verbose );
However, that accepts -V also. So I change it to
use Getopt::Long qw{:config no_ignore_case};
So far so good, but now --v or -ver both work. I thought I could use bundling like
use Getopt::Long qw{:config bundling no_ignore_case};
but it doesn't quite do what I had in mind.
If I use -ver it correctly says
Unknown option: e Unknown option: r
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
|
|---|