#!/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"