http://www.perlmonks.org?node_id=1192255


in reply to Text::CSV_XS function does not accept headers and key together

Nice case, but sory to say, the error is in your code. The key attribute expects a single scalar, not a list:

#!/usr/bin/perl use strict; use warnings; use Text::CSV_XS qw( csv ); my $file = "/home/me/Documents/www/files/data/Miscellany/Magic_items.t +xt"; open my $fh, "<", $file or die "Can't open $file $!"; my $list = csv ( in => $file, sep_char => '|', headers => [ "item", 'seen in" ], key => "item", # SCALAR, not LIST ); use Data::Dumper; print Dumper $list;

Should work exactly as you intend

I'll see if I can make a warning/error for this case


Enjoy, Have FUN! H.Merijn