Thanks for all input. With the code mentioned below that is inspired by your input and some article re. HTML::template on perl.com I've got HTML::template creating a nice table with odd/even rows. Just one thing to work on is how if it were not a single column table. Guess I've got to read the csv that's providing the data for the table into a hash. That'll be a challenge again.
#!/usr/bin/perl -w
use strict;
use diagnostics;
use HTML::Template;
open( OUT, ">fruit.html" ) or die "cant open out $!";
my $html = do{local $/;<DATA>};
my $tpl = HTML::Template->new(
scalarref => \$html,
loop_context_vars => 1,
filter => \&cstmrow_filter
);
my @rows = ( "Apple", "Orange", "Mango", "Kiwi" );
my @loop_data = (); # initialize an array to hold my loop
while (@rows) {
my %row_data; # a hash for my data list
$row_data{FILES} = shift @rows;
push( @loop_data, \%row_data );
}
$tpl->param( rows => \@loop_data );
print OUT $tpl->output;
sub cstmrow_filter {
my $text_ref = shift;
$$text_ref =~ s/<CSTM_ROW\s+EVEN=(.+)\s+ODD=(.*)\s*>
/<TMPL_IF NAME=__odd__>
<tr class="$1">
<TMPL_ELSE>
<tr class="$2">
<\/TMPL_IF>
/gx;
}
__DATA__
<head>
<style type="text/css">
.odd { background-color: #d3d3d3 }
.even { background-color: #90ee90 }
</style>
</head>
<body>
<p>
<table class="center">
<TMPL_LOOP NAME=rows>
<CSTM_ROW EVEN=even ODD=odd>
<td> <TMPL_VAR NAME=FILES></td>
</tr>
</TMPL_LOOP>
</table>
</p>
</body>
</html>