Sure, Perl provides lots of ways of providing inline data that are better than the string of print statements used by the OP. I use DATA a lot for one off scripts that filter data I've copied and pasted from somewhere for example (Clipboard saves the need for paste and DATA though). If I need a fragment of HTML inlined then a HEREDOC is a really good choice because it makes the HTML clear and puts it right where it's used.

However, the big win with using a template system (there are may btw - HTML::Template is a really good starting point) is being able to spin off the HTML into something that is very close to a static page file that a page designer can work on without having to have any understanding of the business code that uses it. Encouraging this usage pattern is why I went to the trouble of creating a test file in the example.

The problem with the DATA section is that it doesn't scale. There is only one of them. Inline data seems rather like peanuts, it's hard to stop at one!

Premature optimization is the root of all job security

In reply to Re^3: perl if statement by GrandFather
in thread perl if statement by Drsin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.