Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Contents of array - Perl DBI question

by Freezer (Sexton)
on Aug 02, 2012 at 18:15 UTC ( #985086=perlquestion: print w/ replies, xml ) Need Help??
Freezer has asked for the wisdom of the Perl Monks concerning the following question:

Hello there,

Please could anyone advise me why my array is something like:

ARRAY(0x943548)ARRAY(0x943548)ARRAY(0x943548)ARRAY(0x943548)
The code that produces this is like:
while(@row_B = $sth_B->fetchrow_array()) { @record_B = @row_B; push(@fields_B, \@record_B); } $sth_B->finish();

Comment on Contents of array - Perl DBI question
Select or Download Code
Replies are listed 'Best First'.
Re: Contents of array - Perl DBI question
by moritz (Cardinal) on Aug 02, 2012 at 18:24 UTC
Re: Contents of array - Perl DBI question
by suaveant (Parson) on Aug 02, 2012 at 18:49 UTC
    To expand on what moritz said, you also don't need to copy @row_B to @record_B before taking a reference. I believe fecthrow_arrayref re-uses the same ref, which requires you to copy the data, but fetchrow_array is returning you the list, so if you use my as moritz said, the ref will change each time you pull a record, simplifying.

    Of course, if all you want is an array of arrays of the data, look at fetchall_arrayref in the DBI documentation

                    - Ant
                    - Some of my best work - (1 2 3)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2015-07-30 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls