#!/usr/bin/perl use strict; use warnings; use DBI; # Connect to the database, (the directory containing our csv file(s)) my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;"); # Associate our csv file with the table name 'prospects' and # manually declare names for each of the columns $dbh->{'csv_tables'}->{'prospects.csv'} = { 'col_names' => ["name", "address", "floors", "donated", "contact"] }; # Output the name and number of floors using our column names my $sth = $dbh->prepare("SELECT * FROM prospects.csv WHERE name LIKE 'G%'"); $sth->execute(); while (my $row = $sth->fetchrow_hashref) { print("name = ", $row->{'name'}, ", Number of floors = ", $row->{'floors'}, "\n"); } $sth->finish();