my $sth = $dbh->prepare("select * from foo"); $sth->execute; print table( Tr [ th($sth->{NAME}), map {map td($_), @$_} $sth->fetchall_arrayref ] );