List Info

Thread: What is this technique called?




What is this technique called?
country flaguser name
United States
2007-05-19 02:17:02


Hello Everyone:

I use this technique all the time to write HTML:
print <<EOM;
....your HTML code here.....

EOM

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?

TIA.

q
__________________________________________________________
Create the ultimate e-mail address book. Import your contacts to Windows Live Hotmail.
www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&;ocid=TXT_TAGLM_HMWL_reten_impcont_0507

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: What is this technique called?
country flaguser name
United States
2007-05-19 05:38:40

>>&gt;>> "essential" == essential quint < quintessential1%40hotmail.com">quintessential1hotmail.com> writes:

essential> Hello Everyone:

essential> I use this technique all the time to write HTML:
essential> print <<EOM;
essential> ....your HTML code here.....

essential> EOM

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&quot;, 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
<; merlyn%40stonehenge.com">merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )