in reply to STDOUT and STDIN question
There are couple of different ways, take a look at perlipc.
For example. Parent:
use strict; use warnings; my $pid = open(KID_TO_READ, "-|", "perl -w b.pl"); while (<KID_TO_READ>) { print "from parent: $_"; }
Child:
use strict; use warnings; print "Hello\n"; print "World\n";
This gives you:
from parent: Hello from parent: World
However this does not handle STDERR, one way to resolve it is to do this in child:
use strict; use warnings; open STDERR, '>&STDOUT'; print "Hello\n"; print STDERR "World\n";
|
|---|