Ok, Here's as far as I've been able to get: #!perl use warnings; use strict;
my @empty = (); open INDEX, "> fieldcontents.txt" or die "can't create fieldcontents.txt $!"; open INPUT, "<lv1.txt" or die "can't open data file: $!"; { while (<INPUT>) { if ($. == 1) { chomp; # remove newline my @headings = split /\t/; # get each of the headings } next if $. == 1 ; chomp; # remove newline my @fields = split /\t/; # get each of the fields for (my $i = 0; $i <= $#fields; $i++) { if (length($fields[$i]) < 1) { $empty[$i] == "x"; print INDEX "$empty[5]\t"; } } print INDEX "\n"; } close INPUT; } close INDEX; I'm having a problem though because the last field in the text file is an alpha field with values like "bosco" and "max" and sometimes no value at all. I keep getting an error "Use of uninitialized value in concatenation <.> or string" and "Use of uninitialized value in numeric eq <==>. If I change the for loop to the following: for (my $i = 0; $i <= $#fields; $i++) { if (length($fields[$i]) < 1) { # $empty[$i] == "x"; print INDEX "$fields[$i]\t$i\t"; } } print INDEX "\n"; I do get a print of the empty indexes but not a real useful one. What am I doing wrong? Thanks, Debbie -----Original Message----- From: Chap Harrison [mailto:[EMAIL PROTECTED] Sent: Monday, November 29, 2004 11:48 PM To: Debbie Cooper Cc: [EMAIL PROTECTED] Subject: Re: Search Tab-delimited file for Null fields > 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>