tags:

views:

224

answers:

1

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";
+4  A: 

You should check out IO::Pipe and FileHandle.

Jonathan Leffler