From: Eric Sunshine Date: Tue, 02 Jul 2024 22:36:44 GMT Subject: Re: [PATCH 1/2] test-lib: allow test snippets as here-docs Message-ID: In-Reply-To: On Tue, Jul 2, 2024 at 5:25 PM Eric Sunshine wrote: > On Mon, Jul 1, 2024 at 8:51 PM Jeff King wrote: > > my $body = substr($$b, $start, pos($$b) - $start); > > + $self->{parser}->{heredoc} .= > > + substr($body, 0, length($body) - length($&)); > > $self->{lineno} += () = $body =~ /\n/sg; > > In my implementation, I use regex to strip off the ending tag before > storing the heredoc body. When I later looked at your implementation, > I noticed that you used substr() -- which seems preferable -- but > discovered that it strips too much in some cases. [...] Nevermind this part. I just looked again at the misbehaving code (which I had commented out but not deleted) and noticed that I botched the implementation in two distinct ways. With those botches removed, the substr() approach works just fine.