5
Tôi viết lại mã cũ của tôi trong phong cách mới, như dưới đây:Làm cách nào để mở các đường ống với kiểu OO?
#old style
open(FD,"file");
#new style
$fh = IO::File->new("file","r");
tập tin là ok, nhưng tôi không biết làm thế nào để mở đường ống.
# read from pipes.
open(PIPE,"some_program |");
# write to pipes.
open(PIPE,"| some_program");
Cách xử lý đường ống trong OO Kiểu IO?
thêm:
cảm ơn Jonathan, không sao.
# 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";