foreach (@SQL_queries) { my $Get_results = $_; my $sth_atl = $dbh->prepare($Get_results) or die "Couldn't prepare query: ".$dbh->errstr; $sth_atl->execute() or die "Couldn't execute query: ".$sth_atl->errstr; my $cols_for_row_B; while ($cols_for_row_B = $sth_atl->fetchrow_array) { local $" = "\t"; print OUTFILE $cols_for_row_B; print OUTFILE "\n"; } } undef @SQL_queries; #### while ($cols_for_row_B = $sth_atl->fetchrow_array) { local $" = "\t"; print OUTFILE $_; print OUTFILE "\n"; }