in reply to Odd and even table rows

You don't actually need to do most of that, all you really need is to swap the value each time...
my $class = "even"; while ($pointer = $sth->fetchrow_hashref) { $class = ($class eq "odd") ? "even" : "odd"; ...more stuff goes here.... }