Perl IPC::运行失败-线束()参数3中出现意外标量
我尝试运行简单的脚本Perl IPC::运行失败-线束()参数3中出现意外标量,perl,ipc,Perl,Ipc,我尝试运行简单的脚本 use IPC::Run qw (run timeout); run "date", \$in, \$out, \$err, timeout( 10 ) or die "err: $?"; print "Date is $out \n"; 但它会错误地失败: Unexpected SCALAR(0x1e52f80) in harness() parameter 3 at t.pl line 2 Unexpected SCALAR(0x1e52f08) in harnes
use IPC::Run qw (run timeout);
run "date", \$in, \$out, \$err, timeout( 10 ) or die "err: $?";
print "Date is $out \n";
但它会错误地失败:
Unexpected SCALAR(0x1e52f80) in harness() parameter 3 at t.pl line 2
Unexpected SCALAR(0x1e52f08) in harness() parameter 4 at t.pl line 2
我使用PerlV5.14和v5.10,尝试不同的服务器。
过程IPC::Run::HARNET(由“Run”命令使用)通过大“if”语句解析循环中的所有传入参数。但是在这个语句中,sclar值没有规则,所以\$out中断了命令 IPC::Run::Run的第一个参数应该是数组引用,而不是标量。所以这是可行的:
run ["date"], \$in, \$out, \$err, timeout( 10 ) or die "err: $?";
这有点难理解,但在
IPC::Run::harness
子例程中,当第一个参数是数组引用时,它会设置一些变量和标志,以便正确处理其余参数。IPC::Run::Run的第一个参数应该是数组引用,而不是标量。所以这是可行的:
run ["date"], \$in, \$out, \$err, timeout( 10 ) or die "err: $?";
这有点难理解,但在IPC::Run::harness
子例程中,当第一个参数是数组引用时,它会设置一些变量和标志,以便正确处理其余参数