私が書いている perl スクリプトには、たくさん (~50) のコマンド ライン オプションが用意されている場合があります。それらのほとんどはオプションであるため、呼び出しには提供されるオプションの一部のみが含まれます。
使用していますが、複数回Getopt::Long
使用することはできません。GetOptions
その結果、1 回のGetOptions
呼び出しですべてのコマンド ライン オプションを使用する必要があります。
使用中にオプションをグループ化する良い方法はありますGetOptions
か?
$ cat test.pl
use strict;
use warnings;
use Getopt::Long;
my ($a, $b, $c, $d);
GetOptions ('a=s' => \$a, 'b=s' => \$b);
GetOptions ('c=s' => \$c, 'd=s' => \$d);
print "a = $a\nb = $b\nc = $c\nd = $d\n";
$ perl test.pl -a=AA -b=BB -c=CC -d=DD
Unknown option: c
Unknown option: d
Use of uninitialized value in concatenation (.) or string at test.pl line 10.
Use of uninitialized value in concatenation (.) or string at test.pl line 10.
a = AA
b = BB
c =
d =
$