This queue is for tickets about the Text-CSV_XS CPAN distribution.

Report information
The Basics

Nobody in particular
CLemmen [...]

(no value)
Broken in:
(no value)
Fixed in:

Subject: 'parse' method accepts incorrect arguments
Date: Wed, 11 Jan 2017 22:10:47 +0000
To: "" <>
From: Charles Stuart Lemmen <>



First some info:


Distro:  Text::CSV_XS – $VERSION   = "1.26";

Perl: This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-thread



Caption                    OperatingSystemSKU  OSProductSuite  Version

Microsoft Windows 10 Home  101                 768             10.0.14393


Next, the issue:


I was using Perl CPAN package “Text::CSV_XS” recently and noticed something odd. I accidentally fed the ‘parse’ method the results from a valid ‘get_line’ method call. ‘parse’ wants a string but I gave it an array ref. What it gave back was an array with one index who’s value was the stringified version of the array ref argument:




No error, no complaints! I had to do some head scratching before I figured out what was going on. I haven’t tried other tests such as feeding ‘parse’ a hash ref but it makes me wonder if, for simplicity sake, ‘parse’ just stringifies whatever is given to it. I think better would be if it used a line such as the below, which would at least eliminate the caller accidentally giving it a ref:


ref $str and croak ‘Argument is a reference not a string!’;


I realize it’s really up to the caller to not do Bad Things in this case but the above is some pretty non-intrusive argument checking.  This could conceivably be considered more a feature request than bug but I’m leaning towards the latter.


Here’s the code I used:


use strict;

use warnings;

use Text::CSV_XS;

use Data::Dumper;

my $csv_file_with_header = 'test_csv_xs.csv';

my $csv = Text::CSV_XS->new({binary => 1, auto_diag => 1, eol => $/});

my $csv_fh;

if(open($csv_fh, "<", $csv_file_with_header)) {

    my $header_rec = $csv->getline($csv_fh) or die $csv->error_diag();

    $csv->parse($header_rec) or die $csv->error_diag();

    my @columns = $csv->fields();

    print Dumper(\@columns) . "\n";

    close $csv_fh;


exit 1;


And here is what the header record looks like:


"Entry Type","Cust ID",Company,"Item ID","Item Ident","Kit ID","Kit Ident","Date Sync",Notes


And here’s the result:


$VAR1 = [




Thanks for writing and maintaining Text::CSV_XS J


Stuart Lemmen

IT Development & Support

Excelsior Integrated LLC


Excelsior Integrated SmallMCM 3PL seal vector


Image displayed inline above

Image displayed inline above

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to