[EMAIL PROTECTED] wrote:
> I am trying to send the output of a mysql query to a two dimensional array.
> 
> This is what I've tried using push.
> 
> while (@results = $sth->fetchrow_array ())
> {
>     $x = $results[0];
>     $y = $results[1];
>     push (@data,[$x],[$y]);
> }
> 
> However, I don't get back a two dimensional array, I get back a single
> array of @data.
> 
> Thanks. -Aaron
> 

Not sure if this is an exercise in how to build an AoA or if you are
really just trying to accomplish the goal and move on. In the latter
case, you can have DBI do it for you using 'fetchall_arrayref',

my $array_of_arrays = $sth->fetchall_arrayref;

use Data::Dumper;
print Dumper($array_of_arrays);

You should probably read the docs for the method, assuming you care
about data integrity and error handling,

http://search.cpan.org/~timb/DBI-1.48/DBI.pm#fetchall_arrayref

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to