Change 28404 broke the construct s/foo/<<BAR/e. So, try to be more
Rafael Garcia-Suarez [Tue, 20 Jun 2006 17:22:15 +0000 (17:22 +0000)]
clever. If the right hand side of s///e contains a #, then maybe
it's a comment, so add a \n after it. Obviously, this is fast, but
won't cover all possible cases.

p4raw-id: //depot/perl@28409

toke.c

diff --git a/toke.c b/toke.c
index 4eef362..ebb3550 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -10720,7 +10720,9 @@ S_scan_subst(pTHX_ char *start)
            sv_catpv(repl, es ? "eval " : "do ");
        sv_catpvs(repl, "{");
        sv_catsv(repl, PL_lex_repl);
-       sv_catpvs(repl, "\n}");
+       if (strchr(SvPVX(PL_lex_repl), '#'))
+           sv_catpvs(repl, "\n");
+       sv_catpvs(repl, "}");
        SvEVALED_on(repl);
        SvREFCNT_dec(PL_lex_repl);
        PL_lex_repl = repl;