Evaluates EXPR and exits immediately with that value. Example:
$ans = <STDIN>;exit 0 if $ans =~ /^[Xx]/;
See alsodie
. If EXPR is omitted, exits with0
status. The only universally recognized values for EXPR are0
for success and1
for error; other values are subject to interpretation depending on the environment in which the Perl program is running. For example, exiting 69 (EX_UNAVAILABLE) from asendmail incoming-mail filter will cause the mailer to return the item undelivered, but that's not true everywhere.
Don't useexit
to abort a subroutine if there's any chance that someone might want to trap whatever error happened. Usedie
instead, which can be trapped by aneval
.
The exit() function does not always exit immediately. It calls any definedEND
routines first, but theseEND
routines may not themselves abort the exit. Likewise any object destructors that need to be called are called before the real exit.END
routines and destructors can change the exit status by modifying$?
. If this is a problem, you can callPOSIX::_exit($status)
to avoid END and destructor processing. Seeperlmod for details.
Portability issues:"exit" in perlport.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.