In perl.git, the branch topic/indented-here-docs has been created

<http://perl5.git.perl.org/perl.git/commitdiff/ff554f6a9f6b0fdffbc2598f4bb17c2f818febf9?hp=0000000000000000000000000000000000000000>

        at  ff554f6a9f6b0fdffbc2598f4bb17c2f818febf9 (commit)

- Log -----------------------------------------------------------------
commit ff554f6a9f6b0fdffbc2598f4bb17c2f818febf9
Author: Matthew Horsfall <[email protected]>
Date:   Thu Jun 30 20:22:48 2016 -0400

    Allow 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 throw warnings.
    
    Some examples:
    
      if (1) {
        print <<~EOF;
        Hello there
        EOF
      }
    
    prints "Hello there\n";
    
    The following:
    
      if (1) {
        print <<~EOF;
       Hello There
        EOF
    
    warns and prints:
    
      Indentation on line 1 of heredoc doesn't match delimiter at 
/home/mhorsfall/eof.pl line 6.
       Hello there
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to