Perl:
use HTML::Template;
...DBI connect, etc. ...
my $stmt = "SELECT id, name FROM sometable";
$sth = $dbh->prepare($stmt);
$sth->execute();
my $options = $sth->fetchall_arrayref({});
$template = HTML::Template->new(filename => 'form.tmpl')
$template -> param(pulldown => $options);
print $template->output();
HTML: