Perl GetOptions() case sensitivity
GetOptions(
"r|repo=s" => 开发者_JAVA技巧 \$repo,
"R|list-repos" => \$list,
);
When I call this script with -r qwe
option, $list
is updated to 1, which is not what I expect.
How can I make GetOpt case sensitive?
use Getopt::Long qw(:config no_ignore_case);
Also enabling bundling fixes it too:
use Getopt::Long qw(:config bundling);
From the documentation:
When configured for bundling, single-character options are matched case sensitive while long options are matched case insensitive. To have the single-character options matched case insensitive as well, use:
Getopt::Long::Configure ("bundling", "ignorecase_always");
And the author adds :
It goes without saying that bundling can be quite confusing.
精彩评论