Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Building an array of hashes from database

by snax (Hermit)
on Sep 26, 2003 at 17:03 UTC ( [id://294497]=note: print w/replies, xml ) Need Help??


in reply to Building an array of hashes from database

As noted above, the hash ref isn't quite right in your code. Try this:
while (my @row = $sth->fetchrow_array()) { push @records, {name => $row[0], ip => $row[1], email => $row[2]}; }
You can drop the my %data; statement using this approach, too. This makes it clear (to my eye, of course) that a new (anonymous) hash ref is used each time around. Check out perlref for more stuff on anonymous data structures and references. Good stuff :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found