develooper Front page | perl.perl5.porters | Postings from April 2010

[perl #2754] [BUG] can't exit 0 from CHECK{}

Thread Previous | Thread Next
From:
Alexandr Ciornii via RT
Date:
April 12, 2010 03:51
Subject:
[perl #2754] [BUG] can't exit 0 from CHECK{}
Message ID:
rt-3.6.HEAD-6227-1271069451-1161.2754-15-0@perl.org
Still present in 5.12.0 RC0.

On Tue Mar 28 03:39:19 2000, tchrist@chthon.perl.com wrote:
> From a CHECK{}, you cannot exit(0).  You may exit !0, but not 0.
> If you put this in /tmp/a and run it:
> 
>     #BEGIN { warn "testing exit from BEGIN"; exit }
>     #BEGIN { warn "testing exit N from BEGIN"; exit 1 }
> 
>     #INIT { warn "testing exit from INIT"; exit }
>     #INIT { warn "testing exit N from INIT"; exit 2 }
> 
>     CHECK { warn "testing exit from CHECK"; exit }
>     #CHECK { warn "testing exit N from CHECK"; exit 3 }
> 
>     #END { warn "testing exit from END"; exit }
>     #END { warn "testing exit N from END"; exit 4 }
> 
>     print "i am now the main program\n";
>     warn "testing exit 5 from main";
>     exit 5;
> 
>     die "XXX";
> 
> You will get:
> 
>     % perl /tmp/a
>     testing exit from CHECK at /tmp/a line 7.
>     i am now the main program
>     testing exit 5 from main at /tmp/a line 14.
>     Exit 5
> 
> If you switch the comment on the two CHECKs, you get
> 
>     % perl /tmp/a
>     testing exit N from CHECK at /tmp/a line 8.
>     Exit 3

-- 
Alexandr Ciornii, http://chorny.net


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About