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

[perl #133123] eval '__PACKAGE__' in debug mode do not return rightpackage

Thread Previous | Thread Next
KES via RT
April 20, 2018 08:18
[perl #133123] eval '__PACKAGE__' in debug mode do not return rightpackage
Message ID:
> outputs:
>     notDB-outer
> (which is what I expect).

Yes, this is right. 
Thus the EXPR which is evaled in 'DB' package sees 'main' package
Does __PACKAGE__ will see also 'main' package or it will see 'DB' pacakge still??

I suppose it does. Because this is 'string eval' which:
> is executed as a block within the lexical context of the current Perl program, any outer lexical variables are visible to it, and any package variable settings

The 'eval' in DB package 
>doesn't see the usual surrounding lexical scope, but rather the scope of the first non-DB piece

The first non-DB piece is 'main' package, thus __PACKAGE__ should return 'main'

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About