>Have you seen the perldoc for system ?>
> Is there a way to have a perl script exit with a status code?
> For instance I have ascript that calls another script via
> I want to then be able to get the exit status of that script.
The return value is the exit status of the program as returned
by the "wait" call. To get the actual exit value divide by 256.
See also the exec entry elsewhere in this doent. This is
*not* what you want to use to capture the output from a command,
for that you should use merely backticks or "qx//", as described
in the section on "`STRING`" in the perlop manpage. Return value
of -1 indicates a failure to start the program (inspect $! for
Like "exec", "system" allows you to lie to a program about its
name if you use the "system PROGRAM LIST" syntax. Again, see the
exec entry elsewhere in this doent.
Because "system" and backticks block "SIGINT" and "SIGQUIT",
killing the program they're running doesn't actually interrupt
args = ("command", "arg1", "arg2");
system(args) == 0
or die "system args failed: $?"
You can check all the failure possibilities by inspecting "$?"
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
When the arguments get executed via the system shell, results
and return codes will be subject to its quirks and capabilities.
See the section on "`STRING`" in the perlop manpage and the exec
entry elsewhere in this doent for details.