0
我认为它是那么容易,因为:如何设置GetOpt的默认值?
my $man = 0;
my $help = 0;
my @compList = ('abc', 'xyz');
my @actionList = ('clean', 'build');
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man, 'complist:[email protected]' => \@compList, 'action:[email protected]' => \@actionList) or pod2usage(2);
然而,当我这样做:
script.pl --action clean
而且打印我actionList
,它只是追加我的参数来结尾:clean build clean
谢谢 - 我已进行了更改,但现在我发现别的东西;只有一个值被保存在数组中:'--complist COMPA COMPB'只产生'COMPA' – MrDuk
Nevermind - 使用'{x,y}'结果是这里的解决方案。 – MrDuk