in reply to
csv file is not opening using use strict
The problem is in print:
print "$fields[0] fields[1]";
That shouuld be
print "$fields[0] $fields[1]";
Note that
my @fields should be parenthesized to get a
list; also, you opened
$data, so don't forget to
close it.
#!/usr/bin/perl -l
BEGIN {
$| = 1;
$^W = 1;
}
use strict;
use autodie;
use warnings;
my $file_c = '/root/Desktop/file1.csv';
open my $data, '<', $file_c
or die "Could not open file: $!";
while ( defined( my $line = <$data> ) ) {
do {
next if ( $. == 1 );
chomp $line;
my (@fields) = split( /,/, $line, 0 );
print "$fields[0] $fields[1]";
};
}
close $data;