in reply to Pipe two child processes

The way to dup a file handle is to use the open NEWHANDLE ">&OLDHANDLE"; form. Or the open NEWHANDLE ">$=$fd" form. If you have a copy of the Camel book look under open.

In your case I would guess that the code to use would be:

pipe READ, WRITE; my $child1 = fork(); unless ($child1) { open STDOUT ">&WRITE"; exec ('cat', $0); } my $child2 = fork (); unless ($child2) { open STDIN "<&READ" or die "Cannot open read filehandle\n"; exec ('grep', 'grep'); } waitpid ($child1, 0); waitpid ($child2, 0);

Of course being an unreformed Perl4 hacker I use file handles, there is no doubt a better way to do it.