【发布时间】:2017-03-24 16:22:44
【问题描述】:
在传递带有选项(包含空格的值)作为参数的 perl 脚本时,空格忽略问题。
test.pl
use strict;
use Getopt::Long;
my $option;
GetOptions(
"myreg=s"=>\$option,
);
print "Option: $option\n";
我有一个 shell 脚本,当我传递带有选项(包含空格的值)的 perl 脚本时,脚本只打印空格之前的选项值。
/my/test/script.sh /my/testing/test.pl --myreg='Reg 1'
上面的执行打印,
Option: Reg
什么问题?请帮忙。
【问题讨论】:
-
Shell 插值和引用。在交给 perl 之前,你的引号会被 shell “解析”。
标签: perl