Use of exit functions in Perl

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.