summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-09-20 21:24:02 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-09-20 21:24:02 -0700
commitaf9838cc2fa3350e15e88a27008899ae3a3afdb6 (patch)
tree8312e06f5b3a831c414acd68fe51ce7c029c4c44 /pp_ctl.c
parentebcfa0534aa7072c0353af79a1e3d7e87678e73e (diff)
downloadperl-af9838cc2fa3350e15e88a27008899ae3a3afdb6.tar.gz
[perl #19078] wrong match order inside replacement
$ perl -le '$_="CCCGGG"; s!.!@a{print("[$&]"),/./}!g' [C] [C] [C] [C] [C] [C] What’s happening is that the s/// does not reset PL_curpm for each iteration, because it doesn’t usually have to. The RHS’s scoping takes care of it most of the time. This happens with the /e modifier and with @{...}. In this example, though, we have a subscript, not a block. This sub- script is in the same scope as the s/// itself. The assumption that the substitution operator will never have to reset PL_curpm itself appears to be incorrect. This fixes it.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 099d2aeb89..0a9dcfedd9 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -377,6 +377,7 @@ PP(pp_substcont)
(void)ReREFCNT_inc(rx);
cx->sb_rxtainted |= RX_MATCH_TAINTED(rx);
rxres_save(&cx->sb_rxres, rx);
+ PL_curpm = pm;
RETURNOP(pm->op_pmstashstartu.op_pmreplstart);
}