从<;运行示例时报告的错误;编程Perl>; pipe(从父级到子级)或die“pipe:$!”; 管道(从子管道到父管道)或模具“管道:$!”; 选择((选择(给子对象),$|=1))[0])#自动冲洗 选择((选择(对父项),$|=1))[0])#自动冲洗 如果($pid=fork){ 从父项关闭;关闭到父项; 打印到_CHILD“父Pid$$正在发送此\n”; chomp($line=); 打印“父Pid$$只需阅读:`$line'\n”; 接近孩子;接近孩子; waitpid($pid,0); }否则{ 模具“不能分叉:$!”除非定义为$pid; 接近孩子;接近孩子; chomp($line=); 打印“子Pid$$只需阅读:`$line'\n”; 打印到父项“子Pid$$正在发送此\n”; 从父项关闭;关闭到父项; 出口 }

从<;运行示例时报告的错误;编程Perl>; pipe(从父级到子级)或die“pipe:$!”; 管道(从子管道到父管道)或模具“管道:$!”; 选择((选择(给子对象),$|=1))[0])#自动冲洗 选择((选择(对父项),$|=1))[0])#自动冲洗 如果($pid=fork){ 从父项关闭;关闭到父项; 打印到_CHILD“父Pid$$正在发送此\n”; chomp($line=); 打印“父Pid$$只需阅读:`$line'\n”; 接近孩子;接近孩子; waitpid($pid,0); }否则{ 模具“不能分叉:$!”除非定义为$pid; 接近孩子;接近孩子; chomp($line=); 打印“子Pid$$只需阅读:`$line'\n”; 打印到父项“子Pid$$正在发送此\n”; 从父项关闭;关闭到父项; 出口 },perl,Perl,它报告没有足够的参数用于选择系统调用 这是什么意思?看起来像是打字错误。实际代码应该如下所示: pipe(FROM_PARENT, TO_CHILD) or die "pipe: $!"; pipe(FROM_CHILD, TO_PARENT) or die "pipe: $!"; select((select(TO_CHILD), $| = 1))[0]); # autoflush select((select(TO_PARENT), $| = 1))[0]); # autoflush if

它报告
没有足够的参数用于选择系统调用


这是什么意思?

看起来像是打字错误。实际代码应该如下所示:

pipe(FROM_PARENT, TO_CHILD) or die "pipe: $!";
pipe(FROM_CHILD, TO_PARENT) or die "pipe: $!";
select((select(TO_CHILD), $| = 1))[0]); # autoflush
select((select(TO_PARENT), $| = 1))[0]); # autoflush
if ($pid = fork) {
    close FROM_PARENT; close TO_PARENT;
    print TO_CHILD "Parent Pid $$ is sending this\n";
    chomp($line = <FROM_CHILD>);
    print "Parent Pid $$ just read this: `$line'\n";
    close FROM_CHILD; close TO_CHILD;
    waitpid($pid,0);
} else {
    die "cannot fork: $!" unless defined $pid;
    close FROM_CHILD; close TO_CHILD;
    chomp($line = <FROM_PARENT>);
    print "Child Pid $$ just read this: `$line'\n";
    print TO_PARENT "Child Pid $$ is sending this\n";
    close FROM_PARENT; close TO_PARENT;
    exit;
}
select((select(TO_CHILD), ($| = 1))[0]); # autoflush
select((select(TO_PARENT), ($| = 1))[0]); # autoflush