script:
#!/usr/bin/perl
use DBI;
use HTML::Template;
use CGI;
my $q = CGI->new();
my $dbh = DBI->connect('DBI:Pg:dbname=testdb', '', '');
$dbh->{RaiseError} = 1;
$aref = $dbh->selectall_arrayref( q/select foo, bar from test_table where id = ?/, { Slice => {} }, $q->param('id') );
$dbh->disconnect;
my $template = HTML::Template->new(filename => 'test.tmpl', associate => $q, global_vars => 1);
$template->param(TEST_LOOP => $aref);
print $template->output();
template:
id =
id:
foo:
bar: