The child process cannot access variables or call subroutines in your process. So your second criteria cannot be met. You will need to have the child write to a pipe from which you will read and write to the tied handle.
use IPC::Open3 qw( open3 );
open(local *CHILD_STDIN, '<', '/dev/null')
or die $!;
my $pid = open3(
'<&CHILD_STDIN',
'>&STDOUT',
local *CHILD_STDERR,
'ls file-that-does-not-exist.txt',
);
while (<CHILD_STDERR>) {
print $tied_fh $_;
}
waitpid($pid, 0);
IPC::Open3 is quite low level. IPC::Run3 and/or IPC::Run can surely make this much simpler.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.