Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
H.Merijn Brand - Tux
committed
Jan 30, 2020
1 parent
62224a5
commit 0db4b1e
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/pro/bin/perl | ||
|
||
use 5.16.2; | ||
use warnings; | ||
|
||
use Text::CSV_XS; | ||
|
||
binmode STDOUT, ":encoding(utf-8)"; | ||
binmode STDERR, ":encoding(utf-8)"; | ||
|
||
my $h = shift // 0; | ||
|
||
sub show { | ||
say join ", " => map { "\x{231e}$_\x{231d}" } @_; | ||
} # show | ||
|
||
my $csv = Text::CSV_XS->new ({ auto_diag => 2 }); | ||
if ($h) { | ||
say "Calling header"; | ||
show ($csv->header (*DATA)); # comment out this line to hide the bug | ||
} | ||
while (my $row = $csv->getline (*DATA)) { | ||
show (@$row); | ||
} | ||
$csv->error_diag; | ||
say "EOF: ", $csv->eof ? "Yes" : "No"; | ||
|
||
__DATA__ | ||
Foo,Bar,Baz | ||
a,xxx,1 | ||
b,"xx"xx", 2 | ||
c, foo , 3 |