diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-11-15 12:38:27 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-15 15:57:13 -0800 |
commit | 4f00fc7eb37048382b2117386a4281be681be957 (patch) | |
tree | 11805f4c184b983bf09d452f9ac08552ff342cce /pod/perlfunc.pod | |
parent | 39fa595e1e5cb4211fbc3905fda0b6d8e5851f6f (diff) | |
download | perl-4f00fc7eb37048382b2117386a4281be681be957.tar.gz |
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
Diffstat (limited to 'pod/perlfunc.pod')
-rw-r--r-- | pod/perlfunc.pod | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 98d7673552..6a7dcdb0dd 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1915,7 +1915,8 @@ errors: C<eval BLOCK> does I<not> count as a loop, so the loop control statements C<next>, C<last>, or C<redo> cannot be used to leave or restart the block. -An C<eval ''> executed within the C<DB> package doesn't see the usual +An C<eval ''> executed within a subroutine defined +in the C<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. You don't normally need to worry about this unless you are writing a Perl debugger. |