This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlfunc: Correct note about eval in DB package
authorFather Chrysostomos <sprout@cpan.org>
Thu, 15 Nov 2012 20:38:27 +0000 (12:38 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 15 Nov 2012 23:57:13 +0000 (15:57 -0800)
commit4f00fc7eb37048382b2117386a4281be681be957
tree11805f4c184b983bf09d452f9ac08552ff342cce
parent39fa595e1e5cb4211fbc3905fda0b6d8e5851f6f
perlfunc: Correct note about eval in DB package

It’s where the subroutine is defined, not the current package,
that matters.

#!perl -l
sub { my $x = 3; foo(); print $x }->();
sub foo { package DB; eval q"$x = 42" }
__END__
3

#!perl -l
sub { my $x = 3; DB::foo(); print $x }->();
package DB;
sub foo { package main; eval q"$x = 42"; }
__END__
42
pod/perlfunc.pod