This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Filtering Here Docs =head1 VERSION Maintainer: Richard Proctor <[EMAIL PROTECTED]> Date: 27 Aug 2000 Version: 1 Mailing List: [EMAIL PROTECTED] Number: 162 =head1 ABSTRACT With a here doc print <<ZZZ; the here doc, is processed verbatum. This results in Here Docs that either stick out in the code, or result in unwanted leading whitespace. There are several FAQs that relate to this problem. This proposal attempts to improve on the concept. =head1 DESCRIPTION I originally wanted to remove leading whitespace from the lines in a heredoc, several other people wanted to remove whitespace equivalent to the shortest span of whitespace at the start of lines, or the whitespace from the first line. TomC pointed out ways to achieve the removal of the whitespace in current perl, although this sort of works (as long as the user is consistent about use of spaces and tabs). I would like to make life easier. This attempts to bring all these ideas together. =head2 Method 1 With an extended definition of a heredoc, eg print <<< FOO; perl looks at the absolute whitespace of the next line, and then removes an equivalent amount from all following lines until the terminator. It only removes whitespace, and it measures whitespace with tabs=8. To do this it would effectively expand the tabs on the lines, and then remove the unwanted whitespace. The problem with this is that if the first line had more whitespace than those that follow, the extra indent for that line would be lost. =head2 Method 2 In a similar way to that described above, perl looks ahead and finds the line with the shortest whitespace, and uses that as the measure of the whitespace to be removed. This will take more to parse, but would I think be closer to what most people would want. =head2 Method 3 Use the existing heredoc and a regex. This is no change for perl6, but does not really address the issue, just because it can be done, does not mean it should not be made easier. Methods 1 and 2 above are compile time, not run time, the existing heredoc and a regex is a runtime solution. =head2 The way forward I personally don't like the status quo from method 3. Method 1 is easier and faster, method 2 is more in line with what is wanted, either would improve the perl programmers lot. =head2 Syntax Here are two methods: print <<< FOO; (As prooposed in RFC 111 V1, this is always different from existing perl programs) print << 'FOO'/x; (/x for eXtended heredoc, the '`" quotes would be required to make the syntax unambiguous I think, other /xyz flags could be added using this syntax, but it could just lead to confusion with an obscure perl program). =head1 IMPLENTATION This should be a relatively simple addition to perl (I think just to scan_heredoc in toke.c + docs in perl5) =head1 REFERENCES RFC111 V1 - Proposed the basic syntax and the removal of all whitespace at the begining of the line. RFC111 V2 - Here Docs Terminators
