The template:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use HTML::Template; my %hash = ( 2 => ['pear', 'icky pineapple',], 3 => ['apple', 'grape',], 5 => ['orange',], ); my $char_loop; for my $key (reverse sort keys %hash) { my $fruit_loop; my @fruits = @{$hash{$key}}; for my $fruit (@fruits){ push @{$fruit_loop}, { fruit => $fruit, }; } push @{$char_loop}, { chars => $key, fruit_loop => $fruit_loop, } } #print Dumper $char_loop; my $t = HTML::Template->new( filename => q|sulferic.html|, ) or die $!; $t->param( char_loop => $char_loop, ); print $t->output(); __DATA__ ---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl <html> <head> <title>HoA</title> </head> <body> <b>5</b><br> <a href="link.pl?=orange">orange</a> <b>3</b><br> <a href="link.pl?=apple">apple</a> <a href="link.pl?=grape">grape</a> <b>2</b><br> <a href="link.pl?=pear">pear</a> <a href="link.pl?=icky pineapple">icky pineapple</a> </body> </html> > Terminated with exit code 0.
<html> <head> <title>HoA</title> </head> <body> <TMPL_LOOP NAME='char_loop'> <b><TMPL_VAR NAME='chars'></b><br> <TMPL_LOOP NAME = 'fruit_loop'> <a href="link.pl?=<TMPL_VAR NAME='fruit'>"> <TMPL_VAR NAME='fruit'> </a> </TMPL_LOOP> </TMPL_LOOP> </body> </html>
tested ;-)
In reply to Re: Custom HOA printing
by wfsp
in thread Custom HOA printing
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |