使用GetOpt :: Long,是否可以創建一個動態參數列表?
Perl Getopt ::長動態參數
myprog.pl --dir/tmp目錄--force --releaes 1.2.3
my %options =();
my @options = qw(dir force release);
#note dir and release take argument, and force is a flag
my $result = GetOptions(\%options, \@optons); #or something like that
print "dir $options{dir} \n"; #produces say /tmp
print "force $options{force} \n"; # produces 1 or 0
print "release $options{release} \n"; # and so on
感謝
當然,可以動態構建有效參數列表;除非您在源代碼中修復它們,否則所有列表都是動態的。 – 2011-04-22 23:59:11