diff options
-rw-r--r-- | op.c | 3 | ||||
-rw-r--r-- | pp_ctl.c | 5 | ||||
-rwxr-xr-x | t/comp/require.t | 15 |
3 files changed, 19 insertions, 4 deletions
@@ -356,8 +356,9 @@ S_pad_findlex(pTHX_ char *name, PADOFFSET newoff, U32 seq, CV* startcv, if (CxREALEVAL(cx)) saweval = i; break; + case OP_DOFILE: case OP_REQUIRE: - /* require must have its own scope */ + /* require/do must have their own scope */ return 0; } break; @@ -2727,8 +2727,11 @@ S_doeval(pTHX_ int gimme, OP** startop) av_store(comppadlist, 1, (SV*)PL_comppad); CvPADLIST(PL_compcv) = comppadlist; - if (!saveop || saveop->op_type != OP_REQUIRE) + if (!saveop || + (saveop->op_type != OP_REQUIRE && saveop->op_type != OP_DOFILE)) + { CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc(caller); + } SAVEFREESV(PL_compcv); diff --git a/t/comp/require.t b/t/comp/require.t index efce899edc..1d92687355 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -7,7 +7,7 @@ BEGIN { # don't make this lexical $i = 1; -print "1..19\n"; +print "1..20\n"; sub do_require { %INC = (); @@ -113,7 +113,18 @@ do_require "1"; print "# $@\nnot " if $@; print "ok ",$i++,"\n"; -END { 1 while unlink 'bleah.pm'; } +# do FILE shouldn't see any outside lexicals +my $x = "ok $i\n"; +write_file("bleah.do", <<EOT); +\$x = "not ok $i\\n"; +EOT +do "bleah.do"; +dofile(); +sub dofile { do "bleah.do"; }; +print $x; +$i++; + +END { 1 while unlink 'bleah.pm'; 1 while unlink 'bleah.do'; } # ***interaction with pod (don't put any thing after here)*** |