in reply to HTML::Template vs. CGI.pm

"... why add the complexity of a separate HTML template ..."

Because someone added the complexity of an HTML coder to your project. Whenever i write a small app for myself, i usually just pick CGI.pm and be done with it, but anything that involves a team, i use a templating system. I started out with HTML::Template and we use HTML::Template were i work, but must confess that Template Toolkit is very fun stuff.

However, another issue arrises when you decide to store your menu in a database. Let's see CGI.pm do this easier! ;) (warning: untested)
$sth = $dbh->prepare("select title,width,height,param,alt from menu"); $sth->execute; $tmpl->param(menu => $sth->fetchall_arrayref({})); print header, $tmpl->output; __DATA__ <tmpl_loop menu> <span class="mitem"> <a title="<tmpl_var title>" href="?a=<tmpl_var param>"> <img height="<tmpl_var height>" border="0" src="i/<tmpl_var param>.png" alt="<tmpl_var alt>" width="<tmpl_var width>" /> &nbsp;<tmpl_var param>&nbsp; </a> </span> </tmpl_loop>
Also, if you use HTML::Template, you should only be using CGI.pm for three things (excluding uploads):
  1. to print the header
  2. to fetch the params
  3. to create form elements
You should not be mixing anything else. See Colorized HTML stack trace and my reply for what i think is a good CGI.pm to H::T conversion.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)