my $p = Page->new(); # now we get the info from the database and pass it to the template # in this case, the template needs a reference to an array of hashes # in order to handle the TMPL_LOOP properly. Which is exactly what # dbselect returns. hard to believe :-) $newst->param(news => $p->dbselect($sql,1)); sub dbselect{ my Page $self = shift; my $sql = shift if @_; my $hash = shift if @_; my $db = $self->db(); my $h = $db->prepare($sql) or $self->errorpage("DB problem in select prepare: " . $db->errstr()); $h->execute() or $self->errorpage("DB problem in select execute: " . $db->errstr()); my $arrayref; if ($hash){ $arrayref = $h->fetchall_arrayref({}); } else { $arrayref = $h->fetchall_arrayref(); } return $arrayref; }