加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl的Getopt :: Long解析参数我没有提前定义吗?

发布时间:2020-12-15 23:29:11 所属栏目:大数据 来源:网络整理
导读:我知道如何使用Perl的Getopt :: Long,但我不知道如何配置它来接受任何未明确定义的“–key = value”对并将其粘贴在哈希中.换句话说,我不知道用户可能想要什么选项,所以我无法定义所有选项,但我希望能够解析所有这些选项. 建议?提前谢谢. 解决方法 Getopt::
我知道如何使用Perl的Getopt :: Long,但我不知道如何配置它来接受任何未明确定义的“–key = value”对并将其粘贴在哈希中.换句话说,我不知道用户可能想要什么选项,所以我无法定义所有选项,但我希望能够解析所有这些选项.

建议?提前谢谢.

解决方法

Getopt::Long文档提供了一个可能有用的配置选项:

pass_through (default: disabled)
             Options that are unknown,ambiguous or supplied
             with an invalid option value are passed through
             in @ARGV instead of being flagged as errors.
             This makes it possible to write wrapper scripts
             that process only part of the user supplied
             command line arguments,and pass the remaining
             options to some other program.

解析常规选项后,您可以使用诸如provided by runrig之类的代码来解析临时选项.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读