#!perl use strict; use warnings; use autodie qw( open close ); use English qw( -no_match_vars ); use Text::CSV_XS; my $csv = Text::CSV_XS->new({ always_quote => 1, binary => 1, eol => $INPUT_RECORD_SEPARATOR, }); binmode STDOUT, ':encoding(UTF-8)'; for my $file (@ARGV) { open my $fh, '<:encoding(UTF-8)', $file; while (my $fields = $csv->getline($fh)) { $csv->print(\*STDOUT, $fields); } $csv->eof() or $csv->error_diag(); close $fh; } exit 0; #### use File::BOM qw( open_bom ); open my $input_fh, '<:via(File::BOM)', $input_file; open my $output_fh, '>:encoding(UTF-8):via(File::BOM)', $output_file;