in reply to Capturing STDERR using IO::Handle

IPC::Open3's open3 is one way.

use IPC::Open3 qw( open3 ); use Symbol qw( gensym ); my $pid = open3( my $to_chld = gensym(), my $fr_chld = gensym(), my $fr_chld_err = gensym(), 'command', 'with', 'args' ); close($to_chld); close($fr_chld); my @logmessages = <$fr_chld_err>; waitpid($pid, 0);

Untested.

Replies are listed 'Best First'.
Re^2: Capturing STDERR using IO::Handle
by xdg (Monsignor) on Nov 26, 2007 at 21:31 UTC

    IO::CaptureOutput is another way.

    use IO::CaptureOutput qw/capture_exec/; my ($stdout, $stderr) = capture_exec( 'command', 'with', 'args' );

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.