This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #36909] $^R undefined on matches involving backreferences
[perl5.git] / regexec.c
index d547ff7..8abe220 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3867,7 +3867,15 @@ NULL
        }
 
        case CURLYX_end: /* just finished matching all of A*B */
-           regcpblow(ST.cp);
+           if (PL_reg_eval_set){
+               SV *pres= GvSV(PL_replgv);
+               SvREFCNT_inc(pres);
+               regcpblow(ST.cp);
+               sv_setsv(GvSV(PL_replgv), pres);
+               SvREFCNT_dec(pres);
+           } else {
+               regcpblow(ST.cp);
+           }
            cur_curlyx = ST.prev_curlyx;
            sayYES;
            /* NOTREACHED */