I have not done this, but the directions seem to indicate something like:
my %hash = (
'Perl Monks' => 'www.perlmonks.org',
'Gossip and Innuendo' => 'www.salon.com',
'Free Software' => 'www.gnu.org'
);
# we need parallel lists for each of the variables
my @label_list; my @url_list;
foreach my $label ( keys %hash ) {
push( @label_list, $label );
push( @url_list, $hash{$label} );
}
my @loop_data = ();
while (@label_list) {
my %row_data = {};
$row_data{'LABEL'} = shift @label_list;
$row_data{'URL'} = shift @url_list;
push( @loop_data, \%row_data );
}
$template->param(THIS_LOOP => \@loop_data);
==========
then in the template:
<TMPL_LOOP NAME="THIS_LOOP">
Hotlink: <A HREF="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="LABEL"></
+A><P>
</TMPL_LOOP>
But this is a guess. I'd do a Data::Dumper print Dumper( @loop_data ) to get a feel for what this has done. :)
Update: Put while loop around the shift bit, based on repson's input. I overlooked the loop around this section of the sample code in the POD for this module.
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.