For what it's worth, I've done a couple of fairly large CGIs (a few thousand lines; almost all template code, which was in turn mostly XHTML, with a dispatch hash and related subs). You break your templates into blocks which can be named or put into vars like you've done above. Then stuff the Template code under __DATA__ and something like-

print CGI::header(); $template->process(\*DATA, $template_data) or warn $Template::ERROR;

Now that that's out there I'd recommend against it. It's okay for standalone, one-off stuff (in fact that's exactly what it's for because all the code is bundled in one file so it's easy to deploy and it's sometimes easier to edit code in one big file than 30 different ones). For stuff with room to grow it's an idea that will come back and bite.

It sounds like you're ready for CGI::Application, Catalyst, and friends. There is a learning curve but those sorts of packages abstract away *so* much many of the messy details (especially Catalyst) that you only realize how awesome it is after doing it manually yourself. Three weeks dedicated to reading docs and writing test code with Catalyst would likely shave at least that much time off a large project done with it.


In reply to Re: tt2 with perl cgi and a csv file by Your Mother
in thread tt2 with perl cgi and a csv file by Gokee2

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.