This script…
#!perl use strict; use warnings; use open qw( :encoding(UTF-8) :std ); use Text::CSV_XS; my $csv = Text::CSV_XS->new({ always_quote => 1, binary => 1, eol => $/, }); while (my $fields = $csv->getline(*ARGV)) { $csv->print(\*STDOUT, $fields); } $csv->eof() or $csv->error_diag(); exit 0;
…produces this output…
"BLACK SPADE SUIT","BLACK HEART SUIT","BLACK DIAMOND SUIT","BLACK CLUB SUIT" "â ","â¥","â¦","â£"
…from this UTF-8 input…
"BLACK SPADE SUIT","BLACK HEART SUIT","BLACK DIAMOND SUIT","BLACK CLUB SUIT" "♠","♥","♦","♣"
Why?
If I remove the use open statement, the output is identical to the input. This is exactly the reverse of the behavior I expect.
I'm using Strawberry Perl 5.12 for Windows and Text::CSV_XS version 0.85.
(I don't know the answer to the question I'm asking despite having dutifully read all the relevant documentation. Just pointing me toward a perldoc page won't help me. Thanks.)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |