my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => "\t", auto_diag => 1, allow_whitespace => 1, }); #### while (my $row = $csv->getline ($fh)) { # Check if the 5th field contains data if ($row->[4] =~ m/\S/) { # more than just whitespace $csv_o->print ($fhv, $row); } else { # sorry, this is not filled: invalid $csv_o->print ($fhi, $row); }