A bit late but here's a way with HTML::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.
The template:
<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

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.