perlfunc
gods
<P>
exit - terminate this program
<P>
<HR>
<P>
exit
<FONT SIZE=-1>EXPR</FONT>
<P>
<HR>
<P>
Evaluates
<FONT SIZE=-1>EXPR</FONT> and exits immediately with that value. (Actually,
it calls any defined <CODE>END</CODE> routines first, but the <CODE>END</CODE> routines may not abort the exit. Likewise any object destructors that need
to be called are called before exit.) Example:
<P>
<PRE> $ans = <STDIN>;
exit 0 if $ans =~ /^[Xx]/;
</PRE>
<P>
See also [perlfunc:die|die()]. If
<FONT SIZE=-1>EXPR</FONT> is omitted, exits with <CODE>0</CODE> status. The only universally portable values for
<FONT SIZE=-1>EXPR</FONT> are <CODE>0</CODE> for success and <CODE>1</CODE> for error; all other values are subject to unpredictable interpretation
depending on the environment in which the Perl program is running.
<P>
You shouldn't use [perlfunc:exit|exit()] to abort a subroutine if there's any chance that someone might want to trap
whatever error happened. Use [perlfunc:die|die()] instead, which can be trapped by an [perlfunc:eval|eval()].
<P>
All <CODE>END{}</CODE> blocks are run at exit time. See [perlman:perlsub|the perlsub manpage] for details.
<HR>