I rewrite my old code in new style, like below:
#old style
open(FD,"file");
#new style
$fh = IO::File->new("file","r");
Files are ok, but I don't know how to open pipes.
# read from pipes.
open(PIPE,"some_program |");
# write to pipes.
open(PIPE,"| some_program");
How to treat pipes in OO Style IO?
adding:
thanks Jonathan, it's fine.
# 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";
You should check out IO::Pipe and FileHandle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With