Trond Michelsen wrote:
On Thu, Oct 21, 2004 at 08:47:48AM -0500, Dave Cash wrote:When I want an array of hashes to hand to TT these days, I've gone ahead and boiled it down to just this:
while (my $rowref = $sth->fetchrow_hashref) {
foreach (my $href = $rowref) {
my %result = %{ $href };
push @notes, \%result;
}
}
Perhaps I'm not following exactly what you're trying to do, but could you just do this?
push @notes, $rowref while my $rowref = $sth->fetchrow_hashref;
According to the DBI documentation, this would be dangerous. Future
versions of DBI may reuse the hashref it returns,
$data = $dbh->selectall_arrayref($sql,{Slice=>{}})
There isn't any reason to iterate over the individual rows when I want it all in a struct, and I take the chance that I'll wind up with code that kills me if they change the innards. Unless I really need it, I don't bother setting up a statement handle any more.
--mark
_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
