while (my $data = $ss->getNextRow()) { # skip lines unless they have the right number of columns next unless $expected_columns == @$data; ... stuff ... }