# split the fields of each record my @fields = split(/,/, $line); # Check if the storeNbr field is empty. If so, write record to error file. if (!length $fields[28]) { print $ERR_FH join (',', @$_), $/ for @data; }