use DBI; use strict; my $dbh = DBI->connect('dbi:Oracle:dev', 'myUser', 'myPass') || die "Cannot connect to database\n", $DBI::Errstr; my $sth = $dbh->prepare("select * from emp"); $sth->execute || die "failed to execute:\n ", $DBI::Errstr; open (FH, ">c:/temp/out.csv") || die "Cannot open file\n"; while (my @row = $sth->fetchrow_array) { print FH join(', ', @row), "\n"; } close FH; $dbh->disconnect;