in reply to Re^5: Speeds vs functionality
in thread Speeds vs functionality
It works on a UTF-16 CSV file.
use v5.14; use strict; use warnings; use utf8; use autodie qw( open close ); use Text::CSV_PP; @ARGV == 1 or die "Usage: perl $0 <CSV file>\n"; my $file = shift; open my $fh, '<:raw:perlio:encoding(UTF-16):crlf', $file; my $csv = Text::CSV_PP->new({ sep_char => '🎬', quote_char => '🎥', escape_char => '🎥', binary => 1, }); my @rows; while (my $row = $csv->getline($fh)) { push @rows, $row; } $csv->eof() or $csv->error_diag(); close $fh; binmode STDOUT, ':raw:perlio::encoding(UTF-16LE):crlf'; for my $row (@rows) { $row->[4] =~ s/\n\s*/, /g; printf "%-24s %s\n", $row->[0], $row->[4]; } exit 0;
See these nodes for an explanation of the UTF-16 PerlIO nonsense required on Microsoft Windows.
|
---|
In Section
Meditations