I am using HTML::Template with great success, but want to iterate through a huge number of template values as part of a form submission checker. Assigning the template variable values is lengthy and repetitive using the only method I know how. I have the template variables names and their required values in a hash, so wouldn't it be nice if I could just iterate through that and churn out the template variables?
So, is there a way to use a variable for all or part of the left hand side of the value pair assigmnent? Or another way to do the same thing?
# how I do it now
$tmpl->param(flag_location => "foo $var bar");
# I have not used hashes here to make it easier
# to see the two things I am trying to do.
# how I want to do it
my $param = 'flag_location';
$tmpl->param($param => "foo $var bar");
# or better still
my $param = 'location';
$tmpl->param("flag_$param" => "foo $var bar");
Also, what is the correct name for the values either side of the '=>' so I can refer to these things correctly in the future?
Evidently I'm a little confused as to the exact usage of this type of assignment and it's limitations, and can't find any good explanations of it anywhere thus far.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.