My Songs

# songs.cgi use DBI; use CGI; use HTML::Template; use strict; my $DBH = DBI->connect( qw(DBI:vendor:database:host user pass), { RaiseError => 1} ); my $CGI = CGI->new(); # grab the stuff from the database my $sth = $DBH->prepare(' select title, artist, album, year from songs '); $sth->execute(); # prepare a data structure for HTML::Template my $rows; push @{$rows}, $_ while $_ = $sth->fetchrow_hashref(); # instantiate the template and substitute the values my $template = HTML::Template->new(filename => 'songs.tmpl'); $template->param(ROWS => $rows); print $CGI->header(); print $template->output(); $DBH->disconnect();