in reply to Creating Stylized Perl Applications With Uniformity (code)

HTML::Template, Template Toolkit, HTML::Mason are the solutions that you need.

If you use these templating solutions correctly, then most of your CGI scripts will consist of 4 parts:

  1. State checking/de-tainting of input variables from the CGI via perl
  2. Data collection via perl, using DBI or whatever other sources are needed
  3. Data processing via perl, translating from any internal storage forms to something that is nearly readable.
  4. HTML output via a template solution, passing data from perl into the template.
This provides the sufficient distinction to avoid mixing HTML and logic that can sometimes bog you down. Once you know your logic for steps 1-3 are in place, you can then tackle the template problem.

Most of the template solutions allow you to include other template pieces to provide consistent elements such as button bars, banner ads, and the like. They also allow you to maintain some style across pages (though you should use CSS for this).

Most of my scripts that I have right now, save for start/end_form, and submit buttons, have no CGI.pm's HTML functions in them, instead relying on TT2 for all output. The only reason I keep the form and submit buttons in the script is that I can keep the persistent state CGI variable and the appropriate values for the submit buttons in the same place; what happens in the HTML output otherwise doesn't affect the CGI logic.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
  • Comment on Re: Creating Stylized Perl Applications With Uniformity (code)