On Mon, Sep 04, 2000 at 05:36:32PM -0700, Nathan Wiger wrote:
> Actually, the two started merged. :-) They were split up after there
> were too many people for RFC 111 but against RFC 162. Personally, I'd
> rather see the recipe method of:
>
> print <<END_OF_DOC =~ s/^\s{0,5}//g;
This still leaves the problem of having to count whitespace and having
to change your regex if you reindent your code. In effect, it causes
whitespace to become significant. Bleh.
> > I can't think of much else I'd want to comment about the end of a
> > here-doc than "this is the end of the here-doc" which is about as
> > useful as "$i++ # add one to $i".
>
> If you have a potentially huge here doc it can help, just like a
> potentially huge if statement:
>
> if ( $cond ) {
>
> # 200 lines pass
>
> } # end if($cond) line 23
There's a big difference. Every code block ends with a '}'. Every
here doc ends with its own custom tag. Thus to state:
print <<EOF;
Four score and seven years ago...
EOF # end of print <<EOF line 23
can currently be better written as:
print <<GETTYSBURG_ADDRESS
Four score and seven years ago...
GETTYSBURG_ADDRESS
The tag itself describes what the text is, similar to the way a
well-named variable describes what's inside of it and removes the need
for a descriptive comment. At a glance one can tell that
'GETTYSBURG_ADDRESS' closes the here-doc containing the Gettysburg
Address, without having to maintain a comment. (I guarantee the line
number mentioned in the comment will not be maintained.)
Another reason for wanting to comment the closing of a code block is
nesting. Simply searching for the previous '{' will not work.
Here-docs cannot be nested and do not have this problem. Simply
searching backwards for your here-doc tag will always work.
--
Michael G Schwern http://www.pobox.com/~schwern/ [EMAIL PROTECTED]
Just Another Stupid Consultant Perl6 Kwalitee Ashuranse
BOFH excuse #356:
the daemons! the daemons! the terrible daemons!