Loading ...
Sorry, an error occurred while loading the content.

What is this technique called?

Expand Messages
  • essential quint
    Hello Everyone: I use this technique all the time to write HTML: print
    Message 1 of 2 , May 19, 2007
    • 0 Attachment
      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]
    • merlyn@stonehenge.com
      ... essential Hello Everyone: essential I use this technique all the time to write HTML: essential print ....your HTML code here.....
      Message 2 of 2 , May 19, 2007
      • 0 Attachment
        >>>>> "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> 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", 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@...> <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!
      Your message has been successfully submitted and would be delivered to recipients shortly.