I can do the following in bash:
output=`command`
retcode=$?
Is there any way to do the same in Perl? Something like this:
$output=`command`
$retcode=???
I can do the following in bash:
output=`command`
retcode=$?
Is there any way to do the same in Perl? Something like this:
$output=`command`
$retcode=???
And since Perl 5.10, you also have ${^CHILD_ERROR_NATIVE}
.
From http://perldoc.perl.org/perl5100delta.html#New-internal-variables :
${^CHILD_ERROR_NATIVE}
This variable gives the native status returned by the last pipe close, backtick command, successful call to wait() or waitpid(), or from the system() operator. See perlvar for details.
You can read the
$?
variable (as in the shell). Fromman perlvar