This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix two minor s//.../e parsing bugs
It may be an odd place to allow comments, but s//"" # hello/e has\
always worked, *unless* there happens to be a null before the first #.
scan_subst in toke.c wraps the replacement text in do { ... } when the
/e flag is present.
It was adding a line break before the final } if the replacement text
contained #, because otherwise the } would be commented out.
But to find the # it was using strchr, which stops at the first null.
So eval "s//'\0'#/e" would fail.
It makes little sense to me to check whether the replacement contains
# before adding the line break. It would be faster just to add the
line break without checking.
But then I discovered this bug:
s//"#" . <<END/e;
foo
END
__END__
Can't find string terminator "END" anywhere before EOF at - line 1.
So now I have two bugs to fix.
The easiest solution seems to be to omit the line break and make the
comment parser skip the } at the end of a s///e replacement.