use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1 }); while (my $r = $sth->fetch) { $csv->print (*STDOUT, $r); }