use DBIx::XHTML_Table; # database credentials - fill in the blanks my ($data_source,$usr,$pass) = (); my $table = DBIx::XHTML_Table->new('DBI:mysql:project', '', ''); $table->exec_query("select * from test"); $table->modify(table => { width => '100%', cellspacing=> '2', cellpadding=>'5', 'border-style' => 'inset', 'border-width' => 'thin', }); $table->modify(th => { style => { color => '#FFFAF0', background => '#4682B4', 'text-align' => 'center', 'text-transform'=> 'uppercase', } },'head'); $table->modify(tr => { style => { background => ['#B0C4DE','#F0F8FF'], } }); $table->modify(td => { style => { 'text-align' => 'left', 'white-space' => 'nowrap', } }); $table->modify(td => { style => { 'text-align' => 'center', 'white-space' => 'nowrap', } },['id']); $table->modify(th => { style => 'background: #FFF0F5' },'id'); $table->map_cell( sub{ my $datum = shift; return qq|"$datum"|; }, ['id']); print $table->output; #### Output as:
Id Value
"1" hello
"2" googbye
"3" friend