my $columns = get_columns($dbh, $table); print @$columns; sub get_columns { my $dbh = shift; my $table = shift; #SQL statement always gauranteed to return 0 rows, #but ALWAYS returns the column names. Basicaly a #portable "DESC $table" my $statement = qq{ SELECT * FROM $table WHERE 1 = 0 }; my $sth = $dbh->prepare($statement); $sth->execute; #Get the column names for the $table return $sth->FETCH('NAME_lc'); }