use strict; use warnings; use Data::Dumper; use DBI; use CGI::Pretty qw(:standard); my $dbh = DBI->connect( qw(DBI:vendor:database:host user pass), {RaiseError=>1}, ); my $sth = $dbh->selectall_arrayref(' SELECT firstname,lastname,login,email FROM student '); print header,start_html, table( Tr( map th($_), ('First Name', 'Last Name',qw(Login Email)), ), map Tr(map td($_),@$_), @$sth ); #### use DBI; use CGI qw(header); use Template; my $dbh = DBI->connect( ... ); my $students = $dbh->selectall_arrayref(' SELECT firstname,lastname,login,email FROM student ',{Slice => {}}); print header; my $tt = Template->new; $tt->process(\*DATA, {students => $students}) || die $tt->error(); __DATA__ [% FOREACH student = students %] [% END %]
Name Login Email
[% student.lastname %], [% student.firstname %] [% student.login %] [% student.email %]
##
## use DBIx::XHTML_Table; use CGI qw(header); print header, DBIx::XHTML_Table ->new(qw(DBI:vendor:database:host user pass)) ->exec_query('SELECT firstname,lastname,login,email FROM student') ->map_cell(sub {my$e=shift;qq|$e|},'email') ->output ;