Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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 如何使用OO样式打开管道?_Perl_Pipe - Fatal编程技术网

Perl 如何使用OO样式打开管道?

Perl 如何使用OO样式打开管道?,perl,pipe,Perl,Pipe,我以新的风格重写了我的旧代码,如下所示: #old style open(FD,"file"); #new style $fh = IO::File->new("file","r"); 文件还可以,但我不知道如何打开管道 # read from pipes. open(PIPE,"some_program |"); # write to pipes. open(PIPE,"| some_program"); 如何在OO风格的IO中处理管道 添加: 谢谢,乔纳森,很好 # read

我以新的风格重写了我的旧代码,如下所示:

#old style
open(FD,"file");

#new style
$fh = IO::File->new("file","r");
文件还可以,但我不知道如何打开管道

# read from pipes.
open(PIPE,"some_program |");

# write to pipes.
open(PIPE,"| some_program");
如何在OO风格的IO中处理管道

添加:
谢谢,乔纳森,很好

# read from pipes.
$pipe = IO::Pipe->new;
$pipe->reader('some_program');
$data = <$pipe>;

# write from pipes.
$pipe = IO::Pipe->new;
$pipe->writer('some_program');
print $pipe "foo,bar,baz";
#从管道中读取。
$pipe=IO::pipe->新建;
$pipe->reader('some_program');
$data=;
#从管道中写入。
$pipe=IO::pipe->新建;
$pipe->writer('some_program');
打印$pipe“foo,bar,baz”;
您应该签出并删除