Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: multidimensional array's

by NetWallah (Abbot)
on Dec 28, 2012 at 20:11 UTC ( #1010742=note: print w/ replies, xml ) Need Help??


in reply to Re^2: multidimensional array's
in thread multidimensional array's

Ah - learned something today - thank you.

I avoid "fetchall_*", because I mostly process a row-at-a-time , and use the clearer syntax of fetchrow_hashref.

The OP's questions were based on managing arrays, and I did not want to bring hashes and confuse that discussion.

Thanks, space_monk.

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius


Comment on Re^3: multidimensional array's
Re^4: multidimensional array's
by emgi (Initiate) on Dec 29, 2012 at 09:20 UTC
    @All: Thnx a lot for your helpful answers.

    With some additional reading and fiddling around with the syntax I have figured this out now.

    my @allrows =(); while ($row = $sth->fetchrow_arrayref() ) { push @allrows,[@$row]; }; my $titlesfound = @allrows; # Contains the number of results #Show that it works: $loopcount = 0; foreach (@allrows) { my $title1 = ($allrows[$loopcount][1]); print "$title1\n"; $loopcount++; };

    /emgi

      If you do not need the @allrows array, it is wasteful to store data into it. Try this instead:
      my $loopcount = 0; while (my $row = $sth->fetchrow_arrayref() ) { my $title1 = $row->[1]; print "$title1\n"; $loopcount++; }; my $titlesfound = $loopcount;

                   "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-07-30 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls