in reply to How can I have both short and long options with Getopt::Long?
use strict; use warnings; use Getopt::Long qw( :config posix_default bundling no_ignore_case ); GetOptions('verbose|v' => \my $opt_verbose) or die("usage\n"); print( $opt_verbose || 0, "\n");
The ones that should work:
>perl 806754.pl -v 1 >perl 806754.pl --verbose 1
The ones that shouldn't work:
>perl 806754.pl -verbose Unknown option: e Unknown option: r Unknown option: b Unknown option: o Unknown option: s Unknown option: e usage >perl 806754.pl --verb Unknown option: verb usage >perl 806754.pl -V Unknown option: V usage >perl 806754.pl --Verbose Unknown option: Verbose usage
6 of 6 tests successful.
|
|---|
| 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 16:16 UTC | |
by ikegami (Patriarch) on Nov 12, 2009 at 16:45 UTC | |
|
Re^2: How can I have both short and long options with Getopt::Long?
by Anonymous Monk on Apr 16, 2014 at 12:46 UTC |