use strict; use warnings; use lib '/var/root/perl5/lib/perl5'; use Text::CSV; my @rows; my $fh; my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute. or die "Cannot use CSV: ".Text::CSV->error_diag (); my $cnt = 0; my @Values; my $dir = './FXE'; foreach my $fp (glob("$dir/*")) { open my $fh, "<:encoding(utf8)", $fp or die "can't open $!"; while ( my $row = $csv->getline( $fh ) ) { if($row->[0] >=1101227) { $Values[$cnt++] = $row->[0]; $Values[$cnt++] += $row->[1]; $Values[$cnt++] += $row->[2]; $Values[$cnt++] += $row->[3]; $Values[$cnt++] = $row->[4]; $Values[$cnt++] = $row->[5]; $Values[$cnt++] = $row->[6]; $Values[$cnt++] = $row->[7]; } } print($cnt); print("\n"); $csv->eof or $csv->error_diag(); close $fh or die "can't close $!"; $cnt=0; }