[% setvar title TITLE %]
|Note: these documents may be out of date. Do not use as reference!|
To see what is currently happening visit http://www.perl6.org/
Here Docs Terminators (Was Whitespace and Here Docs)
Maintainer: Richard Proctor <firstname.lastname@example.org> Date: 16 Aug 2000 Last Modified: 2 Sep 2000 Mailing List: email@example.com Number: 111 Version: 3 Status: Developing
With a here doc print <<ZZZ; the ZZZ has to be at the start of a line and the text of the here doc, is processed verbatum. This results in the terminator sticking out in the body of the document, makes indenting blocks of text difficult and causes errors and confusion.
There are several FAQs that relate to this problem. This proposal tidies this up.
Perl6 should ignore any whitespace before the terminator of a heredoc on any line. Further it should ignore any whitespace ";"s (and comments) that follow the terminator. Perl should also ignore whitespace between the << and the terminator.
Discussion took place on allowing statements following the terminator, but generally these where thought of as a bad idea. So only ";" and comments should occour on the same line.
All of these should work: print <<EOL; EOL print << EOL; EOL print << EOL; EOL; print << EOL EOL; print <<EOL ; EOL # this is the end of the here doc print <<EOL EOL; # this is the end of the here doc print <<EOL ; EOL; # this is the end of the here doc But this should be an error: print <<EOL EOL; $i++;
This should be a relatively simple addition to perl (I think just to scan_heredoc in toke.c + docs in perl5)
RFC111 V1 Had two concepts, one about the terminator and another about the content. This has been split into two concepts, this RFC and RFC 162.
RFC111 V2 Just had the termination issue, and # commets after the terminator
RFC111 V3 Adds the ";" as acceptable after the terminator (and more examples)
RFC162 Filtering Heredocs (was originally part of RFC 111 V1)