从<programming perl =“”> </programming>运行示例时报告错误

时间:2011-09-20 04:50:30

标签: 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 ($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;
}

报告Not enough arguments for select system call

这是什么意思?

1 个答案:

答案 0 :(得分:3)

这看起来像是一个错字。实际代码应如下所示:

select((select(TO_CHILD), ($| = 1))[0]); # autoflush
select((select(TO_PARENT), ($| = 1))[0]); # autoflush