# build multidimensional array from results while (@arr = $sel->fetchrow_array) { push (@drivers, \@arr); # prints the correct data from the db print "arr: @arr\n"; } # prints the right number of ref's print @drivers; # this just prints the commas and the spaces foreach my $item (@drivers) { print "$item->[0], $item->[1], $item->[2]"; }