Although the OO interface to CGI.pm is useful for forms (especially if there are multiple forms on a page with diferent data), I tend to prefer using the exporter interface to CGI.pm.
use CGI qw(:standard *table);
...
print start_table;
while (my $db_data = $sth->fetchrow_arrayref()) {
print Tr(td($db_data));
# other processing in the loop for each element
}
print end_table;