TMTOWTDI. This strikes me as an OK time to use SELECT *:
# Use LIMIT 1 to keep the database from working
# too hard
my $sql = q(SELECT * FROM table LIMIT 1);
my $sth = $dbh->prepare($sql) or die . . . ;
$sth->execute();
my @col_names = keys %{ $sth->fetchrow_hashref };
$sth->finish();
There are most certainly better ways, though.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated