I am testing perl script using this example found on the forum. I took the sample data and put it in a separate file and using an open to try it this way.
I don't understand why I would be getting undef. I am getting the msg:
Use of uninitialized value in join or string at ./h.pl line 15, line 4.
#!/usr/local/bin/perl
use warnings;
use strict;
use Data::Dumper;
use Text::CSV_XS;
open my $fh, '<', 't.out' or die "Unable to open: $!";
my $csv = Text::CSV_XS->new( { sep_char => "\t" } );
my @list;
$csv->column_names ($csv->getline ($fh));
while ( my $hr = $csv->getline_hr($fh) ) {
push @list, $hr->{'Ball'};
}
print "@list\n";
print Dumper(\@list);
Test file (t.out)
Camera Make Camera Model Text Ball Swing
a b c d e
f g h i j
k l m n o
$ od -cx t.out
0000000 C a m e r a M a k e \t C a m e
6143 656d 6172 4d20 6b61 0965 6143 656d
0000020 r a M o d e l \t T e x t \t B a
6172 4d20 646f 6c65 5409 7865 0974 6142
0000040 l l \t S w i n g \n a \t b \t c \t d
6c6c 5309 6977 676e 610a 6209 6309 6409
0000060 \t e \n f \t g \t h \t i \t j \n k \t l
6509 660a 6709 6809 6909 6a09 6b0a 6c09
0000100 \t m \t n \t o \n \0
6d09 6e09 6f09 000a
0000107
Results:
$VAR1 = [
undef,
undef,
undef
];