in reply to Parse one file, send the records to two different files
But my "error" file ends up with 8 million records in it! So I've got something I'm missing here and I was hoping another pair of eyes would catch it.
You're printing the wrong array (@data instead of @fields) to your errors file.
# split the fields of each record my @fields = split(/,/, $line); # Check if the storeNbr field is empty. If so, write record to er +ror file. if (!length $fields[28]) { print $ERR_FH join (',', @$_), $/ for @data; }
@data is where you're accumulating your good records; and every time you find a bad record, you're writing all the good records you've accumulated so far into your errors file, instead of the single bad record.
|
|---|