我的perl脚本中有以下代码:
my $directory; my @files; my $help; my $man; my $verbose; undef $directory; undef @files; undef $help; undef $man; undef $verbose; GetOptions( "dir=s" => \$directory,# optional variable with default value (false) "files=s" => \@files,# optional variable that allows comma-separated # list of file names as well as multiple # occurrenceces of this option. "help|?" => \$help,# optional variable with default value (false) "man" => \$man,# optional variable with default value (false) "verbose" => \$verbose # optional variable with default value (false) ); if (@files) { @files = split(/,/,join(',',@files)); }
处理互斥命令行参数的最佳方法是什么?在我的脚本中,我只希望用户只输入“–dir”或“–files”命令行参数,但不能同时输入两者.反正配置Getopt来执行此操作吗?
谢谢.