This time I'm trying to read through a
tab-delimited text file with the first row containing headers. I want to
print out any field/column name where the entire field is null (meaning
there is no value for that field for any record in the file).
[snip]
I'm thinking that if I read each column into an array element I can then use
parallel arrays to search through the array of fields to get the element
subscript where all values are null and then get the corresponding field
name from another array.

If all you want to do is identify null column(s), it doesn't seem to me that you need to actually accumulate the values from each row (if I'm reading correctly). Just special-case the first record (with "if $. = 1") and split that into @labels; then for every successive record
a) split into @fields, as you're already doing
b) loop through @fields, testing each for non-null and setting a flag in a corresponding array @notempty
c) at EOF, loop through @notempty and, for every element that is still undefined (meaning that you never encountered a non-null value for this column) use the contents of the corresponding @labels array as the column name for your message.


Testing for non-null can be done like so:
if ($var eq "")  ... etc.

Chap
(caveat: a beginner, myself)


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to