I think there's some heavy weather being made of this. So here's my go. :-)

There's not a regex or any html to be seen. Neither is there any 'hard coded' field names. All the data is taken straight from the CGI.pm param method.

This is, imho, the most effiecient way to go. :-)

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; use CGI; use HTML::Template; # create query object with some params # (straight from the docs) :-) my $q = new CGI( { 'dinosaur' => 'barney', 'song' => 'I love you', 'friend' => 'george', } ); # create data structure for HTML::Template my @param_loop = map { {name => $_, value =>$q->param($_), } } $q->param; # get the template from DATA (this would normally be in a file) my @tmpl = <DATA>; # blast off! my $t = HTML::Template->new(arrayref => \@tmpl); $t->param(param_loop => \@param_loop); print $t->output; __DATA__ <html><head><title>template</title></head> <body> <TMPL_LOOP NAME=param_loop> <p><TMPL_VAR NAME=name> -> <TMPL_VAR NAME=value></p> </TMPL_LOOP> </body> </html>
output:
<html><head><title>template</title></head> <body> <p>friend -> george</p> <p>song -> I love you</p> <p>dinosaur -> barney</p> </body>
update:

From the docs:

If a value is not given in the query string, as in the queries "name1=&name2=" or "name1&name2", it will be returned as an empty string.
So you won't get any pesky undefs either.

In reply to Re: Performance Question by wfsp
in thread Performance Question by Anonymous Monk

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.