use Data::Table; use strict; my @headers = qw(Col1 Col2 Col3 Col4 Col5); my @data; while (my @row = $query->fetchrow) { push @data, \@row; } my $table = Data::Table->new(\@data, \@headers, 0); print $table->html;