Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl IPC::运行失败-线束()参数3中出现意外标量_Perl_Ipc - Fatal编程技术网

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
子例程中,当第一个参数是数组引用时,它会设置一些变量和标志,以便正确处理其余参数