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

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

Thread Previous
From:
Abigail
Date:
April 12, 2010 04:12
Subject:
Re: [perl #2754] [BUG] can't exit 0 from CHECK{}
Message ID:
20100412111231.GW17977@almanda
On Mon, Apr 12, 2010 at 03:50:52AM -0700, Alexandr Ciornii via RT wrote:
> 
> 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
> 
>
> Still present in 5.12.0 RC0.


And in 5.12.0-RC5 as well. However, it's not a regression for a recent
Perl. It behaves the same in 5.10.1, 5.8.[89] and 5.6.2.

It is a regression from 5.005_04 though, which will print the expected:

  testing exit from CHECK at bb line 14.



Abigail

Thread Previous


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