From: Ilya Zakharevich <ilya@math.berkeley.edu>
Date: Sun, 19 Jul 1998 18:16:38 +0000 (-0400)
Subject: Compile (?{}) into a correct package
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbce877f83f260d9f1664e6a2860d1dd13e47de9;p=p5sagit%2Fp5-mst-13.2.git

Compile (?{}) into a correct package

	Message-Id: <199807192216.SAA10482@monk.mps.ohio-state.edu>

p4raw-id: //depot/perl@1601
---

diff --git a/pp_ctl.c b/pp_ctl.c
index 0750220..68c50a5 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2252,6 +2252,10 @@ sv_compile_2op(SV *sv, OP** startop, char *code, AV** avp)
     SAVETMPS;
     /* switch to eval mode */
 
+    if (PL_curcop == &PL_compiling) {
+	SAVESPTR(PL_compiling.cop_stash);
+	PL_compiling.cop_stash = PL_curstash;
+    }
     SAVESPTR(PL_compiling.cop_filegv);
     SAVEI16(PL_compiling.cop_line);
     sprintf(tmpbuf, "_<(%.10s_eval %lu)", code, (unsigned long)++PL_evalseq);
diff --git a/t/op/pat.t b/t/op/pat.t
index f16783e..7d4278f 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -4,7 +4,7 @@
 # the format supported by op/regexp.t.  If you want to add a test
 # that does fit that format, add it to op/re_tests, not here.
 
-print "1..139\n";
+print "1..141\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -534,6 +534,19 @@ $test++;
   print "ok $test\n";
   $test++;
 }
+
+{
+  package aa;
+  $c = 2;
+  $::c = 3;
+  '' =~ /(?{ $c = 4 })/;
+  print "not " unless $c == 4;
+}
+print "ok $test\n";
+$test++;
+print "not " unless $c == 3;
+print "ok $test\n";
+$test++;  
   
 sub must_warn_pat {
     my $warn_pat = shift;