$dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\|}, {RaiseError => 1} ); # here goes the $sth->prepare .... $sth->execute(); while (my @result = $sth->fetchrow_array()) { print $result[0], ", " # first field $result[1], ", " # second field and so on "\n" } $sth->finish(); $dbh->disconnect();