my $sth1 = $dbh->table_info(); while (my(@tab) = $sth1->fetchrow_array()) { push @colNames, $tab[2]; } ... my $sth2 = $dbh->column_info() while (my @info = $sth->fetchrow_array()) { if ($colName eq $info[2]) { print OUT "\t$info[3]\n"; } #END IF }#END WHILE