use DBI;
use Data::Dumper;
my $dbh = DBI->connect( ... );
# Example 1: List of Lists
print Dumper $dbh->selectall_arrayref('select id,name from status');
# Example 2: List of Hashes
print Dumper $dbh->selectall_arrayref(
'select id,name from status',
{ Slice=>{} },
);
####
my $rslt = $dbh->selectall_arrayref('select name,id from status');
my %hash = map @$_, @$rslt;
print Dumper \%hash;
####
use DBI;
use HTML::Template;
my $dbh = DBI->connect(
qw(DBI:vendor:database:host user pass),
{RaiseError=>1},
);
my $things = $dbh->selectall_arrayref('
SELECT id,name
FROM status
',{Slice=>{}});
# optionally do more things to some of the fields
# yes, we do have to say their names again
$_->{id} = sprintf("%03d",$_->{id}) for @$things;
my $tmpl = HTML::Template->new(filehandle => \*DATA);
$tmpl->param(things => $things);
print $tmpl->output;
__DATA__
: