my $csv = Text::CSV->new({ binary => 1, eol => $/ }) or die Text::CSV->error_diag; open my $fh, "<", $file or die "$file: $!"; while ( my $row = $csv->getline($fh) ) { handle_row($row); } $csv->eof or $csv->error_diag(); close $fh; sub handle_row { # ... }