tags:

views:

40

answers:

2

hi friends

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

+4  A: 

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

slebetman
A: 

You can call exit from your perl with code 1, for example:

exit 1 if ($EXIT_STATUS  == 1);

http://perldoc.perl.org/functions/exit.html

Prix