Congradulations! You just re-invented CGI.pm's popup_menu(). samtregar (the author of HTML::Template) recommends using CGI.pm for this very thing. Here is a quick example (with validation!):
use strict; use warnings; use HTML::Template; use CGI qw(:standard); my @color = qw(red green blue black purple orange); my %valid = map {$_ => 1} @color; my $tmpl = HTML::Template->new(filehandle => *DATA); my $color = param('color'); my $select = popup_menu( -name => 'color', -values => [@color], -default => $color, ); $tmpl->param(error => 1) unless $valid{$color}; $tmpl->param( colors => $select, color => $color, ); print header, $tmpl->output; __DATA__ <form> <p> Pick a color: <tmpl_var colors> </p> <input type="submit"> </form> <tmpl_if color> <p><hr/></p> <tmpl_unless error> You picked <span style="color: <tmpl_var color>;"><tmpl_var color></span> <tmpl_else> Invalid choice, "<tmpl_var color>" </tmpl_unless> </tmpl_if>
Now then, you say that you use 'the same type of code to build 6 other select lists' ... why not use one function to handle them all? ;) (and don't say because they have different 'business rules' ... if that's the case, do the extra specific stuff first, then call popup_menu()). Happy coding to ya. :)

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)

In reply to (jeffa) 2Re: HTML:Template Limitation? by jeffa
in thread HTML:Template Limitation? by digger

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.