in my little perl script (test.pl) I do the following in order to exit from program if EXIT_STATUS equal to 1
if ( $EXIT_STATUS == 1 )
{
system (exit);
}
but I need also to get from the test.pl return code 1
for example
./test.pl
echo $?
how to enable return code 1 if EXIT_STATUS = 1 ?
lidia
That's not how you should exit in perl. It's:
if ($EXIT_STATUS == 1) {
exit 1;
}
and if you want to exit normally otherwise:
if ($EXIT_STATUS == 1) {
exit 1;
}
else {
exit 0;
}
or (depending on your intention) more simply:
exit $EXIT_STATUS;
see: http://perldoc.perl.org/functions/exit.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With