use strict; use warnings; use IO::Handle; use Text::CSV_XS; open my $fh, "<", "data.csv" or die "data.csv: $!"; my $csv = Text::CSV_XS->new ({ binary => 1 }); while (my $row = $csv->getline ($fh)) { my ($server, @data) = @$row; $data[0] ||= 0; # ... more processing } close $fh;