in reply to Re^2: Using IPC::Open3 instead of backtick operator
in thread Using IPC::Open3 instead of backtick operator

Depending on configuration, IPC::Cmd will use either IPC::Run or IPC:Open3, so will capture STDERR as well as STDOUT.

Called with 1 buffer, IPC::Cmd will put both STDOUT and STDERR in that buffer. Called in list context, it will return seperate buffers for STDOUT and STDERR.

  • Comment on Re^3: Using IPC::Open3 instead of backtick operator

Replies are listed 'Best First'.
Re^4: Using IPC::Open3 instead of backtick operator
by ikegami (Patriarch) on Jun 10, 2016 at 18:18 UTC
    use strict; use warnings; use IPC::Cmd qw( run ); my $tool = 'tar'; my $cmd = [ 'perl', '-e', 'warn "TEST FAILED IF YOU SEE THIS\n"' ]; my $buffer = ''; my @out = run( command => $cmd, buffer => \$buffer, verbose => 1 );
    $ perl z.pl Running [perl -e warn "TEST FAILED IF YOU SEE THIS\n"]... TEST FAILED IF YOU SEE THIS

    However, one simply has to remove verbose => 1 to make this a solution.