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

[perl #78634] Conflict in defining constant INIT with INIT blocks results in weird errors

Thread Next
From:
Father Chrysostomos via RT
Date:
November 14, 2010 13:54
Subject:
[perl #78634] Conflict in defining constant INIT with INIT blocks results in weird errors
Message ID:
rt-3.6.HEAD-13564-1289771675-1944.78634-14-0@perl.org
On Wed Oct 27 01:21:39 2010, voropaev.andrey@gmail.com wrote:
> One of my modules was defining constant INIT. After switching to
>    perl5.12 the module
> stopped working and the error was
> 
> Undefined subroutine &main::Needed called.
> INIT failed--call queue aborted.
> 
> This didn't make any sense because there's no such function Needed in
>    my module. I could
> reduce the code to the following code
> 
> ###########################################################
> use strict;
> 
> 
> MyPackage::close_cnx();
> 
> package MyPackage;
> use strict;
> 
> use constant INIT => 4;
> 
> 
> sub close_cnx
> {
>     my $self = shift;
>     init_action($self);
> }
> 
> sub init_action
> {
>     my $self = shift;
>     return if $self->{Needed} <= $self->{count};
>     callit($self->{ID}, INIT);
> }
> #####################################################
> 
> The funniest thing is, if you switch the positions of init_action and
>    close_cnx functions,
> then no error is displayed and perl runs fine.

This was caused by:

commit f7461760003db2ce68155c97ea6c1658e96fcd27
Author: Zefram <zefram fysh.org>
Date:   Sun Nov 8 15:03:45 2009 +0100

    Bareword sub lookups


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