Try fetchrow_hashref() instead of fetchrow_arrayref(). You are using Data::Dumper. It dumps. It does not format. You have to do the formatting yourself. Read up of Perl hashes for a start.
--
Andreas
Comment on Re^7: Writing Multiple Recordsets into a CSV file