clarify eval $string scope in docs
authorDavid Mitchell <davem@iabyn.com>
Mon, 6 Jun 2011 10:19:37 +0000 (11:19 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 6 Jun 2011 10:19:37 +0000 (11:19 +0100)
[perl #88014] demonstrated that the docs for string eval misleadingly
implied that the code wasn't executed within new new block scope,
leading to false expectations that $1 etc would retain their values
outside the eval.

pod/perlfunc.pod

index 91a19a2..54f5ae2 100644 (file)
@@ -1592,9 +1592,12 @@ X<error, handling> X<exception, handling>
 In the first form, the return value of EXPR is parsed and executed as if it
 were a little Perl program.  The value of the expression (which is itself
 determined within scalar context) is first parsed, and if there were no
-errors, executed in the lexical context of the current Perl program, so
-that any variable settings or subroutine and format definitions remain
-afterwards.  Note that the value is parsed every time the C<eval> executes.
+errors, executed as a block within the lexical context of the current Perl
+program. This means, that in particular, any outer lexical variables are
+visible to it, and any package variable settings or subroutine and format
+definitions remain afterwards.
+
+Note that the value is parsed every time the C<eval> executes.
 If EXPR is omitted, evaluates C<$_>.  This form is typically used to
 delay parsing and subsequent execution of the text of EXPR until run time.