|Don't ask to ask, just ask|
Here, doccy doccy. nice doccy. heredoc, treat.by Vynce (Friar)
|on Jun 21, 2001 at 05:56 UTC||Need Help??|
Today in the Chatterbox, maddfisherman had some questions about the heredoc quoting mechanism, and OeufMayo and i started answering him, and brought up some things that tinman didn't know, and that brought up stuff none of us knew, so we ran some test scripts and found some interesting things.
first, some things i did know:
as the experienced heredoc user should know, this prints something like
Note that with no quotes, double quote interpolation is implied. (note, too, that your date probaby differs from mine.)
but what if you want to use other quoting mechaisms? i wanted to put a big long list into a qw(), and i tried
but it can't find string terminator qw.
can't find string terminator >.
did better, but only because i consider the runtime error Can't locate object method "Baz" via package "HERE" at everywhere.pl line 23. to be better than not compiling. next step? well, this won't work:
because the $bar in qw() is not interpolated. this brings up the interesting point of how qw works. further tests seem to indicate that all the quoting functions (q, qq, qr, qw, and qx currently, and i think we get more in perl6) are hard to use with heredocs. in fact, aside from trivial cases, they seem to be hard to use, until you realize that they are operators and not functions. which brings up more questions, like "can we get at the underlying functions?" and "if so, how?" things along those lines.
so, uh, perhaps a heredoc tutorial and a quoters tutorial would be in order..
update: fixed some links. and no, CheeseLord i can't think of any specific reason to do it with qw//, but with some of the forthcoming quoting operators, maybe.
update 2: fixed IMPLIED as implied by Particle. bad copying on my part..