<?xml version="1.0" encoding="windows-1252"?>
<node id="314" title="perlfunc:exit" created="1999-08-24 18:43:11" updated="2005-08-13 01:33:11">
<type id="119">
perlfunc</type>
<author id="114">
gods</author>
<data>
<field name="doctext">
</field>
<field name="name">

&lt;P&gt;
exit - terminate this program

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="synopsis">

&lt;P&gt;
exit 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt;

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="description">

&lt;P&gt;
Evaluates 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; and exits immediately with that value. (Actually,
it calls any defined &lt;CODE&gt;END&lt;/CODE&gt; routines first, but the &lt;CODE&gt;END&lt;/CODE&gt; routines may not abort the exit. Likewise any object destructors that need
to be called are called before exit.) Example:

&lt;P&gt;
&lt;PRE&gt;    $ans = &amp;lt;STDIN&amp;gt;;
    exit 0 if $ans =~ /^&amp;#091;Xx&amp;#093;/;
&lt;/PRE&gt;
&lt;P&gt;
See also [perlfunc:die|die()]. If 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; is omitted, exits with &lt;CODE&gt;0&lt;/CODE&gt; status. The only universally portable values for 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; are &lt;CODE&gt;0&lt;/CODE&gt; for success and &lt;CODE&gt;1&lt;/CODE&gt; for error; all other values are subject to unpredictable interpretation
depending on the environment in which the Perl program is running.

&lt;P&gt;
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()].

&lt;P&gt;
All &lt;CODE&gt;END{}&lt;/CODE&gt; blocks are run at exit time. See [perlman:perlsub|the perlsub manpage] for details.

&lt;HR&gt;
</field>
</data>
</node>
