in reply to Capturing STDERR (this is not a FAQ)
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.
IPC::Open3 is quite low level. IPC::Run3 and/or IPC::Run can surely make this much simpler.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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Capturing STDERR (this is not a FAQ)
by mikosullivan (Novice) on Feb 10, 2015 at 06:52 UTC | |
by BrowserUk (Patriarch) on Feb 10, 2015 at 07:16 UTC | |
by BillKSmith (Monsignor) on Feb 10, 2015 at 13:59 UTC | |
by ikegami (Patriarch) on Feb 10, 2015 at 14:58 UTC | |
by ikegami (Patriarch) on Feb 10, 2015 at 14:57 UTC | |
|