Or, since you used the keyword "database", how about:
use strict;
use warnings;
use DBI;
open my $fOut, '>', "delme" or die "Can't create deleme.txt: $!\n";
print $fOut <<FILE;
Line,Name,Colour,Comment
1,Fred,Blue,"Comment with a comma, and stuff."
2,Joe,Green,No comma so no need for quotes
3,Bob,Red,"""A comma, and quotes"""
4,Sam,Yellow,"Penultimate line, but
split across two input lines"
5,Bill,Violet,And an ordinary line to finish
FILE
close $fOut;
my $dbh = DBI->connect('dbi:CSV:', '', '', {f_file => 'delme'});
my $sth = $dbh->prepare("select * from delme");
$sth->execute();
while (my $row = $sth->fetchrow_hashref()) {
print "$_: '$row->{$_}'\n" for sort keys %$row;
print "\n";
}
Prints:
colour: 'Blue'
comment: 'Comment with a comma, and stuff.'
line: '1'
name: 'Fred'
colour: 'Green'
comment: 'No comma so no need for quotes'
line: '2'
name: 'Joe'
colour: 'Red'
comment: '"A comma, and quotes"'
line: '3'
name: 'Bob'
colour: 'Yellow'
comment: 'Penultimate line, but
split across two input lines'
line: '4'
name: 'Sam'
colour: 'Violet'
comment: 'And an ordinary line to finish'
line: '5'
name: 'Bill'
No serious intent that you should use this for your current problem, but it does go some way to show just how flexible DBI is!
Perl is the programming world's equivalent of English