【发布时间】:2014-05-15 23:26:39
【问题描述】:
我认为这很简单:
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:s@' => \@compList, 'action:s@' => \@actionList) or pod2usage(2);
但是,当我这样做时:
script.pl --action clean
我打印我的actionList,它只是将我的参数附加到末尾:clean build clean
【问题讨论】:
标签: perl command-line-arguments getopt