in reply to DBD::CSV and fetchrow_hashref not working

The first question would be: "Does the CSV have a header line, or can it be made to have a header line?". If so, your initialisation could be much simpler. And the ~ does not have to be escaped at all.

$ cat data/objectives-cqdc.txt Obj~PosNbr~Year~Div~AVP~Dept~SDescr~Major~Methods~Results~Accompl~JanU +p~LDescr~Changes~Chars~Goals~Budget~CFObj 20140000020~00001576~2014~"testdata"~"testdata"~"testdata"~-~0~-~"Inse +rted on December 10, 2013"~-~-~-~-~20000000001~20130000001~1~- $ cat test.pl use 5.16.2; use warnings; use DBI; use Data::Peek; my ($Cposition, $Cyear) = ("00001576", 2014); my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => "data", f_ext => ".txt/r", csv_sep_char => "~", }); my $sth = $dbh->prepare (qq{select * from "objectives-cqdc" where PosN +br = ? and year = ?}); $sth->execute ($Cposition, $Cyear); while (my $row = $sth->fetchrow_hashref) { DDumper $row; } $ perl test.pl { accompl => '-', avp => 'testdata', budget => 1, cfobj => '- ', changes => '-', chars => '20000000001', dept => 'testdata', div => 'testdata', goals => '20130000001', janup => '-', ldescr => '-', major => 0, methods => '-', obj => '20140000020', posnbr => '00001576', results => 'Inserted on December 10, 2013', sdescr => '-', year => 2014 } $

Also note that file has been deprecated in favor of f_file to be more consistent with DBD::File specifications. An aditional disadvantage of using specific csv_tables initialisation is that the table name in not case insensitive anymore and that the initialisation takes MUCH longer, as DBD::CSV will scan the default f_dir (defaults to ".") for usable table names possible taking a lot of IO you do not want. Your new code when not having a header could look like this:

use DBI; use Data::Peek; my ($Cposition, $Cyear) = ("00001576", 2014); my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { csv_sep_char => "~", csv_tables => { JPDObj => { f_file => "data/objectives-cqdc.txt", col_names => [qw( Obj PosNbr Year Div AVP Dept SDescr Major Methods Resu +lts Accompl JanUp LDescr Changes Chars Goals Budget CFObj +)], }, } }); my $sth = $dbh->prepare (qq{select * from JPDObj where PosNbr = ? and +year = ?}); $sth->execute ($Cposition, $Cyear); while (my $row = $sth->fetchrow_hashref) { DDumper $row; }

Enjoy, Have FUN! H.Merijn