develooper Front page | perl.perl5.porters | Postings from January 2005

Re: [perl #32562] __PACKAGE__ symbol has wrong value after evalor require

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
January 3, 2005 08:56
Subject:
Re: [perl #32562] __PACKAGE__ symbol has wrong value after evalor require
Message ID:
20050103165622.1894.12@llama.ing-simmons.net
Rafael Garcia-Suarez <rgarciasuarez@mandrakesoft.com> writes:
>Mark-Jason Dominus (via RT) wrote:
>> 
>>         perl -le 'package D; eval q{print __PACKAGE__}'
>> 
>> This prints "main", but it should print "D".
>
>This very simple patch appears to fix it :

It may _change_ it, but is it a fix?
__PACKAGE__ reflects the current package of the lexical scope.
eval "" and require start a new scope.


>
>--- toke.c      (revision 4047)
>+++ toke.c      (working copy)
>@@ -4305,7 +4305,7 @@
>        case KEY___PACKAGE__:
>            yylval.opval = (OP*)newSVOP(OP_CONST, 0,
>                                        (PL_curstash
>-                                        ? newSVsv(PL_curstname)
>+                                        ? newSVpv(HvNAME(PL_curstash), 0)
>                                         : &PL_sv_undef));
>            TERM(THING);
> 
>End.
>
>Now, this might be only an indication of a deeper problem with PL_curstname,
>which might not be correctly set everytime it should.


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