I tend to either use hashes or bound values more than arrays anyway.
I use HTML::Template quite a bit and often use the hashref/arrayref calls to match up with a template. For example:
This is from some code that I'm hacking about at the moment, this matches up to a nested <TMPL_LOOP> in the template.my @nodes = (); my $sth = $dbh->prepare(q{ SELECT node_id, title, body FROM node WHERE parent_id = ? }); $sth->execute($parent_id); while (my $row = $sth->fetchrow_hashref) { push @nodes, $row; } $sth->finish; foreach my $node (@nodes) { $sth->execute($node->{node_id}); $node->{children} = $sth->fetchall_arrayref({ node_id => 1, title => 1 }); $sth->finish; } $t->param(NODES => \@nodes);
It's not designed for performance. If it isn't fast enough then there is loads of things I'd do before changing hashes to arrays...
gav^
In reply to Re: Using hashes instead of arrays with database results
by gav^
in thread Using hashes instead of arrays with database results
by trs80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |