Use of exit functions in Perl
O exit expr
O exit
This function calculates the expr value as an integer and uses this value as the finalProgramError status
Exit. If expr is omitted, the function exits as 0 (meaning "no error ").
At the same time, if the function is in the 0 state, it indicates that the program is successfully launched. If it is in the 1 state, it indicates that the program fails to be executed.
Later. Of course, the function status can also take other values, but the eyes are specific to the running environment of Perl.
The following is a program fragment that allows the user to exit the program by typing X or X:
$ Ans =
Exit if $ ans = ~ /^ [XX]/;
If someone else has any chance to capture any errorsExit is not recommended.
Sub-Process. Die should be used, which can be captured with an eval. Or use the die of the carp module.
Encapsulation, such as croak or confess.
We say that the exit function exits immediately, but this is a naked lie. It exits as soon as possible,
It first calls any defined end process for Exit Processing. These processes cannot exit
Exit, although they can be set by $? Variable changes the final exit value. Similarly, any defined
The classes of the destroy method call this method on behalf of all its objects before the program actually exits. If you
Ignore Exit Processing, so you can call the POSIX module's _ exit function to avoid all
End and destructor processing. If POSIX is not available, you can EXEC "/bin/false" or
Something similar.