in reply to How can I have both short and long options with Getopt::Long?

This works for me:

$ cat 3perl.pl use strict; use warnings; use 5.010; use Getopt::Long; Getopt::Long::Configure(qw{no_auto_abbrev no_ignore_case_always}); my $verbose = ""; GetOptions ('verbose|v' => \$verbose); say $verbose;
$ perl 3perl.pl -v 1 $ perl 3perl.pl -V Unknown option: V $ perl 3perl.pl -verbose 1 $ perl 3perl.pl -Verbose Unknown option: Verbose $ perl 3perl.pl -ver Unknown option: ver

Replies are listed 'Best First'.
Re^2: How can I have both short and long options with Getopt::Long?
by almut (Canon) on Nov 12, 2009 at 13:24 UTC

    If I'm understanding the OP correctly, those two cases should be considered an error, too:

    $ ./806698.pl -verbose 1 $ ./806698.pl --v 1

    (the former case could be solved with bundling, but the latter would then still be accepted)

Re^2: How can I have both short and long options with Getopt::Long?
by 7stud (Deacon) on Nov 12, 2009 at 13:03 UTC

    Some more:

    $ perl 3perl.pl --verbose 1 $ perl 3perl.pl --Verbose Unknown option: Verbose $ perl 3perl.pl --ver Unknown option: ver