in reply to Re^2: Split pattern doesn't match last line of file
in thread Split pattern doesn't match last line of file

It shouldn't be that much trouble. If the OP script works most of the time (except when there's a file with a blank line), then just adding the "next" statement as shown (first line of code inside the while loop) should work all the time:
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; my %saldi; while (<>) { next unless ( /,/ ); ## add this line my @cellen = ( split /,/, )[ 3, 4 ]; $saldi{ $cellen[0] } += $cellen[1]; if ( eof(ARGV) ) { $ARGV =~ m/^(\S+)\.txt/; print "$1\n"; foreach my $name ( keys %saldi ) { print "\t$name\t$saldi{$name}\n"; } } }