Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Pushing Array ref to array

by tobyink (Canon)
on Feb 01, 2012 at 16:10 UTC ( [id://951257]=note: print w/replies, xml ) Need Help??


in reply to Pushing Array ref to array

Ditch your my @row near the top of the script, and do your loop like this:

while (my @row = $sth->fetchrow_array())

In your current code, the scope for @row is too large, so you're effectively pushing multiple references to the same array onto @results.

As a general rule, always declare a variable as close as possible to where it's going to be used.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found