Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How does DBI return an arrayref with key/value pairs?

by PerlSufi (Friar)
on Jun 21, 2013 at 14:23 UTC ( #1040180=note: print w/ replies, xml ) Need Help??


in reply to How does DBI return an arrayref with key/value pairs?

Hello, I'm not sure I completely understand your question, but I have used a little of the DBI module to produce excel sheets.
I did something like this:

my $row=0; my $col=0; $xWS->write($row, $col++, $_) for @{$sth->{NAME}}; # Read the query results and write them into the spreadsheet while (my $ar=$sth->fetchrow_arrayref) { ++$row; $col=0; $xWS2->write($row, $col++, $_) for @$ar; }
Actually, I won't take much credit for that. I found something similar on the perlmonks site itself. I hope this helps..


Comment on Re: How does DBI return an arrayref with key/value pairs?
Download Code
Replies are listed 'Best First'.
Re^2: How does DBI return an arrayref with key/value pairs?
by walkingthecow (Friar) on Jun 21, 2013 at 14:26 UTC
    I can understand the misunderstanding here since my wording may not be the best on this one. I am asking how DBI does it, not how to do with DBI (i.e., how does vs. how to). The code in my question works, but I don't fully understand how it works. I don't get how the arrayref that gets returned has values that can be accessed with a key.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-07-30 01:39 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 (269 votes), past polls