my $sth = $dbh->prepare($sql); $sth->execute() || die $sth->errstr; my $columns = $sth->{NAME}; print IN join( "\t", @{ $columns } ), "\n"; while ( my @row = $sth->fetchrow_array ) { print IN join("\t", @row), "\n"; }