develooper Front page | perl.perl5.porters | Postings from August 2016

Re: Indented here docs?

Thread Previous | Thread Next
David Nicol
August 4, 2016 07:34
Re: Indented here docs?
Message ID:
Furthermore, is the tilde supposed to be part of the chevron or part of the
delimiter? Without space allowed between them it appears to be a new
operator, making it part of the chevron, but by allowing space both before
and after, that introduces a new kind of token, the "heredoc modifier," of
which there is only currently one defined, which is tilde.

Having introduced this new kind of token, it then becomes possible to
declare ways to do the whole heredoc post-processing wishlist:

 << ~  EOF    the original, contents must be indented the same as line
where the expression the chevron appears in starts, under pain of error,
and that indentation is stripped

 << ~. EOF   chop the trailing newline

 << ~^ EOF   traditional heredoc semantics, allowing other modifiers
without discarding leading space

 << ~/^[ \t]*|#.*// EOF impose an arbitrary s///mg on the doc

 << ~^.{ MyFilter } EOF  the same as MyFilter(do { my $tmp = <<EOF; chop
$tmp; $tmp})

"It's like a whole other country."

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About