The Text::CSV module is a great solution for this. Another option is the DBD::CSV module, which provides a slightly different interface. The DBI interface is really useful if you're developing applications that have to access data from different forms of databases, including relational databases and comma-separated text files.
Here's some example code:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
$dbh = DBI->connect ("DBI:CSV:f_dir=/home/joe/csvdb")
or die "Cannot connect: $DBI::errstr";
$sth = $dbh->prepare ("SELECT id, name FROM info.txt WHERE id > 1 ORDER by id");
$std->execute;
my ($id,$name);
$sth->bind_columns (\$id, \$name);
while ($sth->fetch) {
print "Found result row: id = $id, name = $name\n";
}
$sth->finish;
I'd use Text::CSV for this task unless you're planning on talking to other types of databases, but in Perl TIMTOWDI and it helps to know your options.