http://qs321.pair.com?node_id=780067

GertMT has asked for the wisdom of the Perl Monks concerning the following question:

The following code that I use to import some csv file works okay if I do not use
#!/usr/bin/perl -w use strict;
However I get warnings ("uninitialized value") if I'm trying to code the right way. Can someone point me further in the right direction?
Thanks for your reply,
Gert
#!/usr/bin/perl -w use IO::File; use Text::CSV_XS; my $csv = Text::CSV_XS->new( { sep_char => ',' } ); my $io = IO::File->new( 'data.txt', '<' ) or die "Can't read file: $!\n"; my $number = 10; # which number to start with? until ( $io->eof ) { my $row = $csv->getline($io); print "Olah:","\t", $number++ , "\t", $row->[2], " ", "\"", $row->[5], "\"", "\t", "\"", $row->[3], $row[0], "\"", " ", $row->[4], "\n"; }
with data: data.txt
"123",20090626,14,"P8","Ba",20090626,"BET 98" "123",20090626,74,"P2","Ba",20090626,"BET 08" "123",20090626,47,"03","Av",20090626,"f: 29" "123",20090626,40,"10","Av",20090626,"ok" "123",20090629,17,"07","Go",20090629,"Sa"