in reply to how to split html printout into two table cells

I would definately use a Templating solution. It's easier to maintain when you move your presentation out of your code.

Do the sort in the database using ORDER BY.

Here is some code to get you started

use strict; use warnings; use Template; my %vars; $vars{list} = [ qw/apple pear cherry orange kiwi banana lemon lime /]; $vars{cols} = 3; $vars{end} = $#{$vars{list}}; print "$vars{end}\n"; #### TEMPLATE INLINE FOR EXAMPLE my $template = qq| <table> [% cnt = 0 %] [% FOREACH item = list %] [% IF !(cnt % cols) %]<tr>[% END %] <td>[% item %]</td> [% IF ((cnt % cols) == (cols - 1) or (cnt == end)) %]</tr +>[% END %] [% cnt = cnt + 1 %] [% END %] </table> |; my $tt = Template->new(); $tt->process(\$template,\%vars) || die "Template process failed: ", $t +t->error(), "\n";

grep
XP matters not. Look at me. Judge me by my XP, do you?