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.
In reply to Re: How can I have both short and long options with Getopt::Long?
by ikegami
in thread How can I have both short and long options with Getopt::Long?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |