What is this technique called?
- Hello Everyone:
I use this technique all the time to write HTML:
....your HTML code here.....
But I dont know what it's called, so I was wondering if anyone can tell me what the technique is?
Also, I'm a bit comfy with it, but are there any drawbacks to using it? I find I can put entire pages of HTML (even headers and direct references to $variables) into CGI easily using the technique above. It almost seems too good to be true, so I wonder what the catch is.
Also, why did people design modules like HTML::Mason or HTML::Template, when the above technique seems to work just as well?
Create the ultimate e-mail address book. Import your contacts to Windows Live Hotmail.
[Non-text portions of this message have been removed]
>>>>> "essential" == essential quint <quintessential1@...> writes:essential> Hello Everyone:
essential> I use this technique all the time to write HTML:
essential> print <<EOM;
essential> ....your HTML code here.....
essential> But I dont know what it's called, so I was wondering if anyone can tell me what the technique is?
That's called a "here-doc" or a "here-string", because that's what it was
called in the Bourne Shell docs, where a lot of us cut our teeth.
essential> Also, I'm a bit comfy with it, but are there any drawbacks to using
essential> it? I find I can put entire pages of HTML (even headers and direct
essential> references to $variables) into CGI easily using the technique
essential> above. It almost seems too good to be true, so I wonder what the
essential> catch is.
Look into any of the templating systems, like HTML::Template, or Template
Toolkit. You'll find that here-docs really don't cut it when you get above a
few paragraphs of text, in spite of the dozens of counter-examples you'll see
on the net (mostly written in 1996). The modern way is to use a full
MVC-system, like Catalyst or Jifty or Bigtop, or my roll-your-own
CGI::Prototype for the controller and Template for the view.
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!