[Perl] examples of IO::Pipe and IO:Handle

David Baird david.baird at homemail.com
Mon Oct 28 01:27:23 PST 2002


Does anyone have an example of using IO::Pipe to open a child process
which pipes its output to the parent, so the parent can capture the
output character by character (instead of newline by newline)?

I want to use the builtin function read() to capture the input from
the child. I also cannot wait for the child process to terminate before
acting on the output, which is why I cannot use the open() function with
a pipe. The child process is also a Perl script, and I cannot change
it, like to change $| to 1.

So, I would like to create the child process with IO::Pipe through a fork
as is written in the perldoc page, and use IO::Handle::autoflush to force
flushing every character rather than every newline (which may never occur).


David Baird




More information about the Perl mailing list