#! /usr/bin/perl use strict ; use warnings ; use DBI ; use Text::CSV_XS ; my $dbh = DBI->connect( 'DBI:Pg:dbname=odms', 'doug', '' ) or die "Couldn't connect: $!" ; my $csv = new Text::CSV_XS ; my $sth = $dbh->prepare( 'select * from v_doc_list' ) ; $sth->execute ; while ( my $ary_ref = $sth->fetchrow_arrayref ) { $csv->combine( @$ary_ref ) or warn "Error: could not construct CSV string from [@$ary_ref]" ; print $csv->string, "\n" ; } $dbh->disconnect ; exit ;