#!/usr/bin/perl use v5.12; use warnings; use autodie qw( :all ); use DBI; use DBD::CSV (); # v----- adjust to working version if ($DBD::CSV::VERSION < 0.50) { require File::BOM; my $old_connect=\&DBD::CSV::dr::connect; my $new_connect=sub { my ($drh, $dbname, $user, $auth, $attr) = @_; if ($attr && exists($attr->{'csv_bom'}) && $attr->{'csv_bom'}) { delete $attr->{'csv_bom'}; $attr->{'f_encoding'}='utf-8):via(File::BOM'; } goto $old_connect; }; do { no strict 'refs'; no warnings 'redefine'; *DBD::CSV::dr::connect=$new_connect; }; } open my $h,'>:encoding(utf-8)','test.csv'; say $h qq<\x{FEFF}"foo","bar","baz">; say $h qq<"1","2","3">; say $h qq<"4","5","6">; close $h; my $dbh=DBI->connect( 'dbi:CSV:', undef, undef, { RaiseError => 1, PrintError => 0, f_ext => '.csv', csv_bom => 1, } ); my $sth=$dbh->prepare('select * from test'); $sth->execute(); while (my @a=$sth->fetchrow_array()) { say join(",",@a); } $sth->finish();