use strict; use HTML::Template; my $html = do{local $/;}; my %hash = map { $_ => chr $_ } (97..122); my ($i,$j) = (0,0); my $max = 5; my $table; for (sort keys %hash) { push @{$table->[$j]->{key}},{key => $_}; push @{$table->[$j]->{val}},{val => $hash{$_}}; $j++ unless ++$i % $max; } my $tmpl = HTML::Template->new( scalarref => \$html, ); $tmpl->param( table => $table ); print $tmpl->output; __DATA__
Key
Val