On Thu, Apr 19, 2018 at 07:06:06AM -0700, KES wrote: > [DOC](https://perldoc.perl.org/functions/eval.html) > >An eval '' executed within a subroutine defined in the DB package doesn't > see the usual surrounding lexical scope, but rather the scope of the first > non-DB piece of code that called it That paragraph says nothing about about the package an eval is executed; it refers purely to what *lexical* scope is seen in. This code: my $x = 'outer'; package notDB { sub f { my $x = 'notDB'; eval '$x' } } package DB { sub f { my $x = 'DB'; eval '$x' } } print notDB::f(), "-", DB::f(), "\n"; outputs: notDB-outer (which is what I expect). > How to reproduce: > > $ cat Devel/DB.pm > package DB; > > > sub DB { > print eval '__PACKAGE__'; > } > > 1; > > $ cat t.pl > print __PACKAGE__; > > $ perl -d:DB t.pl > DBmain > > Expected: > mainmain I would expect DBmain. -- "Foul and greedy Dwarf - you have eaten the last candle." -- "Hordes of the Things", BBC Radio.Thread Previous | Thread Next