Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: HTML::Template Tutorial

by Anonymous Monk
on Dec 03, 2017 at 21:53 UTC ( #1204823=note: print w/replies, xml ) Need Help??


in reply to HTML::Template Tutorial

My also be useful to use a "better" SQL statement, and "miss" the conversion in Perl. So instead of:
# 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();
Use:
# grab the stuff from the database my $rows = $DBH->selectall_arrayref(' select title, artist, album, year from songs', Slice => {} );
This creates an array of hashrefs directly - see the DBI docs for more details.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1204823]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2021-10-21 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (83 votes). Check out past polls.

    Notices?