我用新风格重写了旧代码,如下所示:
#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 Style IO 中的管道?
adding:
谢谢乔纳森,没关系。
# 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";
你应该检查一下IO::Pipe http://perldoc.perl.org/IO/Pipe.html and 文件句柄 http://perldoc.perl.org/FileHandle.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)