In perl.git, the branch smoke-me/alh/indented-heredocs has been created

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

        at  a065337c6f20128a5563210e03ff3d9295a1c040 (commit)

- Log -----------------------------------------------------------------
commit a065337c6f20128a5563210e03ff3d9295a1c040
Author: Abigail <abig...@abigail.be>
Date:   Sat Nov 12 16:37:48 2016 +0100

    Undocument the need of the absence of space.
    
    Since we no longer require that with here-docs, an unquoted terminator
    follows the << without any whitespace in between, we no longer need
    to document this.

M       pod/perlop.pod

commit 435f02aec5d3e11d04cb36288314fc38690087b0
Author: Matthew Horsfall <wolfs...@gmail.com>
Date:   Fri Nov 11 06:35:32 2016 -0500

    Document Indented Here-docs

M       pod/perldiag.pod
M       pod/perlop.pod

commit 3c17474f99382e75e6541d46fc37896382e8237f
Author: Matthew Horsfall <wolfs...@gmail.com>
Date:   Fri Nov 11 04:58:18 2016 -0500

    Add indented here-docs.
    
    This adds a new modifier '~' to here-docs 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 here-doc, 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 here-doc doesn't match delimiter at - line 2.

M       pod/perldiag.pod
M       t/lib/warnings/toke
M       t/op/exec.t
M       t/op/heredoc.t
M       toke.c

commit 981f4010c806ce68c251251139ce956da6f151f9
Author: Matthew Horsfall <wolfs...@gmail.com>
Date:   Sat Nov 12 09:24:24 2016 -0500

    Allow spaces between << and delimiter in here-doc
    
    Previusly the following program would fail:
    
      print << EOF;
      hi
      EOF
    
    Like so:
    
      Use of bare << to mean <<"" is deprecated at test.pl line 1.
      Bareword found where operator expected at test.pl line 1, near "EOF"
            (Missing operator before EOF?)
      syntax error at test.pl line 1, near "EOF"
      Execution of test.pl aborted due to compilation errors.
    
    This seemed strange because we allow:
    
      << 'EOF';
      << "EOF":
      << `EOF`;
    
    Now, "<< EOF" and "<< \EOF" work just like the others do.

M       t/op/heredoc.t
M       toke.c
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to