Subject: | no_pass_through allows extra args |
The no_pass_through (default) doesn't allow extra options, but does allow extra arguments:
use strict;
use warnings;
use Getopt::Long qw(:config no_pass_through);
GetOptions ("length=i" => \my $length) or die 'error';
print "Length: $length\n";
If you do:
perl getopt.pl --length 5 extra_arg
You get:
Length: 5
Even though extra_arg is passed and length only accepts one value. However, if we do:
perl getopt.pl --length 5 --extra_arg
Then you get:
Unknown option: extra_arg
error at getopt.pl line 5.
It seems like the first case to be consistent should maybe give an error like:
Unknown argument: extra_arg
error at getopt.pl line 5