http://www.perlmonks.org?node_id=1170243


in reply to CSV column names

If you haven't enabled skip_first_row (you have not in this script) and info.csv has all of the column names defined in the first row then you should be able to use col_names.

I just threw this together. It is untested!

#!/bin/env perl use strict; use warnings; use DBI; my $dbh = DBI->connect('DBI:CSV:'); $dbh->{csv_tables}{info} = { file => 'info.csv' }; my $qu = $dbh->prepare('select * from info'); $qu->execute(); my @cols = @{$dbh->{csv_tables}{info}{col_names}}; # col_names won't b +e defined until you've queried the file. print "column names: @cols\n"; while( my @row = $qu->fetchrow_array) { print "row: @row\n"; }

Update: Corrected script.