【发布时间】:2018-07-02 07:14:19
【问题描述】:
我有一个现有的 Perl 脚本,它有许多使用Getopt::Std(getopts 函数)处理的命令行选项。但是,我想添加 2 个新选项:--testrun 和 --cfgarray。
我使用了use Getopt::Long; 和GetOptions('testrun' => \$test_flag); “--testrun” 没有参数。我只是将它用作if($test_flag) 之类的标志。它在单独运行时起作用。但是,由于在我的 Perl 脚本中同时存在 use Getopt::Long; 和 use Getopt::Std;,我得到了错误:
未知选项
来自getopts api(当它在GetOptions 之前调用时)。 Getopt::Std 和 Getopt::Long 可以在单个 Perl 脚本中使用吗?
【问题讨论】:
标签: perl getopt getopt-long