use warnings; use strict; use DBI; my $dbh = DBI->connect("dbi:CSV:", undef, undef, { csv_sep_char => "\t", f_ext => '', RaiseError => 1, }) or die "Cannot connect: $DBI::errstr"; my $sth = $dbh->prepare(<<'ENDSQL'); SELECT tmp01.PeptideID as PeptideID, tmp01.ProteinID as ProteinID, tmp02.SpectrumID as SpectrumID, tmp02.Sequence as Sequence FROM tmp01 LEFT OUTER JOIN tmp02 ON tmp01.PeptideID = tmp02.PeptideID ENDSQL $sth->execute; print join("\t", @{ $sth->{NAME} } ), "\n"; while ( my $row = $sth->fetchrow_arrayref ) { print join("\t", @$row ), "\n"; }