In perl.git, the branch alh/indented-here-docs has been created
<http://perl5.git.perl.org/perl.git/commitdiff/6a2791c99022793bc1f5c92fc38d1d1039de1daa?hp=0000000000000000000000000000000000000000>
at 6a2791c99022793bc1f5c92fc38d1d1039de1daa (commit)
- Log -----------------------------------------------------------------
commit 6a2791c99022793bc1f5c92fc38d1d1039de1daa
Author: Matthew Horsfall <[email protected]>
Date: Fri Nov 11 06:35:32 2016 -0500
Document Indented Heredocs
M pod/perlop.pod
commit ec684f594abacad62c8902a425a14d9052c4ada1
Author: Matthew Horsfall <[email protected]>
Date: Fri Nov 11 04:58:18 2016 -0500
Add indented heredocs.
This adds a new modifier '~' to heredocs that tells the parser
that it should look for /^\s*$DELIM\n/ as the closing delimiter.
These syntaxes are all supported:
<<~EOF;
<<~'EOF';
<<~"EOF";
<<~\EOF;
The '~' modifier will strip, from each line in the heredoc, the
same whitespace that appears before the delimiter.
Newlines will be copied as is, and lines that don't include the
proper beginning whitespace will cause perl to croak.
Some examples:
if (1) {
print <<~EOF;
Hello there
EOF
}
prints "Hello there\n";
The following:
if (1) {
print <<~EOF;
Hello There
EOF
}
croaks with:
Indentation on line 1 of heredoc doesn't match delimiter at - line 2.
M pod/perldiag.pod
M t/op/exec.t
M t/op/heredoc.t
M toke.c
-----------------------------------------------------------------------
--
Perl5 Master Repository