while (<>) { next if m/^\s+$/; # <-- add this line my @cellen = ( split /,/, )[ 3, 4 ]; #### next if $_ =~ m/^\s+$/; #### while ( my $line = <>) { next if $line =~ m/^\s+$/; # <-- add this line my @cellen = ( split( /,/, $line ) )[ 3, 4 ];