#!/usr/bin/env perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV::->new(); while (my $row = $csv->getline(*DATA)) { # Do something with all elements, e.g. print 'Elements: ', 0+@$row, '; Last: |', $row->[-1], "|\n"; } __DATA__ 1,,3,4,,, 1,,3,4,,,not_empty , 800,900,"1,000" #### Elements: 7; Last: || Elements: 7; Last: |not_empty| Elements: 1; Last: || Elements: 2; Last: || Elements: 3; Last: |1,000|