我知道如何使用Perl的Getopt :: Long,但我不知道如何配置它来接受任何未明确定义的“–key = value”对并将其粘贴在哈希中.换句话说,我不知道用户可能想要什么选项,所以我无法定义所有选项,但我希望能够解析所有这些选项.
@H_403_12@解决方法
建议?提前谢谢.
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之类的代码来解析临时选项.