diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-08-20 12:57:29 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-21 14:11:01 -0700 |
commit | 565b52dfca4375468541e36d53e8a2aba372c056 (patch) | |
tree | 4f816fcf51789e90a5c5c29abeb2ddd93b009d93 /t/base | |
parent | 458391bde9932f85da1dbbd0c2a3fdc3229bb00d (diff) | |
download | perl-565b52dfca4375468541e36d53e8a2aba372c056.tar.gz |
heredoc after "" in s/// in eval
This works fine:
eval ' s//<<END.""/e; print
Just another Perl hacker,
END
'or die $@
__END__
Just another Perl hacker,
But this doesn’t:
eval ' s//"$1".<<END/e; print
Just another Perl hacker,
END
'or die $@
__END__
Can't find string terminator "END" anywhere before EOF at (eval 1) line 1.
It fails because PL_sublex_info.super_buf*, added by commit
0244c3a403, are not localised, so, after the "", s/// sees its own
buffer pointers in those variables, instead of its parent string eval.
This used to happen only with s///e inside s///e, but that was because
here-docs would peek inside the parent linestr buffer only inside
s///e, and not other quote-like operators. That was fixed in
recent commits.
Simply moving the assignment of super_buf* into sublex_push does solve
the bug for a simple "", as "" does sublex_start, but not sublex_push.
We do need to localise those variables for "${\''}", however.
Diffstat (limited to 't/base')
-rw-r--r-- | t/base/lex.t | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t index ce16ef122e..d55b189bfa 100644 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..57\n"; +print "1..58\n"; $x = 'x'; @@ -273,3 +273,10 @@ $test++; @a = (1,2,3); print "not " unless($a[~~2] == 3); print "ok 57\n"; + +$_ = ""; +eval 's/(?:)/"${\q||}".<<\END/e; +ok 58 - heredoc after "" in s/// in eval +END +'; +print $_ || "not ok 58\n"; |