Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: An Array Without and Index

by aaron_baugher (Deacon)
on Aug 13, 2012 at 12:32 UTC ( #987105=note: print w/ replies, xml ) Need Help??


in reply to An Array Without and Index

All arrays have an index, so that's not the problem here. Other people have given you good advice about using placeholders, moving your prepare statement outside your loop, etc. But to narrow down your problem, try adding some debugging statements, like this:

print "Fetching values for $addr\n"; while (my @row = $stm->fetchrow_array){ print " Got values: ", join( ':', @row ), "\n"; push (@results, @row); } $stm->finish; print "Finished getting values, printing \@results for $addr:\n"; print join ':', @results; print "\n\n";

Aaron B.
Available for small or large Perl jobs; see my home node.


Comment on Re: An Array Without and Index
Download Code
Re^2: An Array Without and Index
by Anonymous Monk on Aug 13, 2012 at 12:51 UTC

    try adding some debugging statements, like this:

    No :) use Data::Dump / Data::Dumper... for visualizing data structures

      I use those a lot, to the point where I'm thinking of putting 'use Data::Printer' in the blank template I use to start a new Perl script, since I always end up adding it during testing anyway. But in this case, there are two reasons I didn't:

      • Those modules print several lines to show a single value. That's fine to display a single structure once at a certain point, but to do it repeatedly in a loop can give you a heap of output that would be difficult for a newbie to parse through.
      • I have a feeling his real problem is with program flow. I think he's going to discover that where he thinks he's seeing the whole array printed, he's really seeing one element of the array printed each time through the loop, but with nothing else being printed between them, they look like one output. To see that, he doesn't need to see the structure of @results just once; he needs to see how his program is flowing and how that array is changing with each step.

      So in this case, in my opinion, changing my print/join statements to 'print Dumper @results' could make it harder for him to see the problem.

      Aaron B.
      Available for small or large Perl jobs; see my home node.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-09-18 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (126 votes), past polls