#!/usr/local/bin/perl use DBI; my $dbh = DBI->connect( "DBI:CSV:f_dir=/export/home/temp;csv_eol=\n;csv_sep_char=!;", {RaiseError=>1}, ); $dbh->{'csv_tables'}->{'datainfo'} = { 'file' => 'datainfo.data', # 'sep_char' => "!", 'quote_char' => undef, 'escape_char' => undef, 'col_names' => ["id", "class", "name", "instructor"] }; my ($query) = "select distinct id, class from datainfo "; my ($sth) = $dbh->prepare($query); $sth->execute(); while (my $row = $sth->fetchrow_hashref) { print ("ID =", $row->{'id'}, "\n\t CLASS = ", $row->{'class'}, "\n"); } print "\n";