Well, one thing about them that might catch some by surprise is that a here-doc comes in two pieces and those two pieces can end up pretty far apart. Take an example:
print <<FOO, <<'BAR';
Usage: $0 [arguments]
FOO
This program doesn't do much.
BAR
If here-docs were just like strings and didn't come in two parts, then you'd want to write that more like:
print <<FOO
Usage: $0 [arguments]
FOO, <<'BAR'
This program doesn't do much.
BAR;
which doesn't work. You can write it like this:
print <<FOO
Usage: $0 [arguments]
FOO
, <<'BAR'
This program doesn't do much.
BAR
;
but I think the first example is easier to read.
-
tye
(but my friends call me "Tye") |