in reply to Capture return value from a cmd when it errors
Backticks (or qx//) capture output to STDOUT, but not to STDERR. For an easy solution, see Capture::Tiny.
Update: For example (adapted from the documentation):
use Capture::Tiny ':all'; my $cmd = ... my @args = ... print "Start of my code\n"; my ($stdout, $stderr, $exit) = capture { system($cmd, @args); }; print "Exit status is : $exit\n"; if ($exit) { print "Error in executing command : $stderr\n"; exit; } print $stdout;
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|