in reply to Problem with passing my script's STDIN to child

You need to setup a pipe from your parent to your child. I believe IO::Pipe will facilitate this. It's been quite a while since I've had to do it so I can't really give you a concrete example.

Update: I actually spent some time and came up with a simple example.

use IO::Pipe; $pipe = new IO::Pipe; if($pid = fork()) { $pipe->writer(); while(<STDIN>) { print $pipe $_; } } else { $pipe->reader(); while(<$pipe>) { $line = $_; print "CHILD: $line"; } }
For some reason the data isn't pushed through the pipe until you end the input stream (^D) setting $| didn't seem to help.

Replies are listed 'Best First'.
Re^2: Problem with passing my script's STDIN to child
by jdalbec (Deacon) on Aug 21, 2004 at 02:11 UTC
    That's because $| affects only the currently select()ed output filehandle. IO::Pipe appears to subclass IO::Handle so you can just change
    $pipe->writer();
    to
    $pipe->writer(); $pipe->autoflush();