【发布时间】:2016-06-30 08:17:09
【问题描述】:
我的 perl 脚本在解析命令行参数时遇到问题。主要是,我希望 perl 解析以 (em/en)-dash 和 hypen 开头的参数。 请考虑以下命令执行:
my_spript.pl -firstParam someValue –secondParam someValue2
如您所见,firstParam 以 hypen 为前缀,perl 解析它没有问题,但 secondParam 以 en-dash 为前缀,不幸的是 Perl 无法将其识别为参数。 我正在使用 GetOptions() 来解析参数:
GetOptions(
"firstParam" => \$firstParam,
"secondParam" => \$secondParam
)
【问题讨论】:
-
你使用什么模块? Getopt::Long?
-
@choroba,是的。我确实使用 Getopt::Long
-
恕我直言,这是一个疯狂的要求。
标签: perl parsing arguments args hyphen