in reply to Delete the line

I suspect you are new to Perl, the comments in the code below are intended to be educational. I have used a couple of things you may not have seen before, @array[2..$#array] is a slice of an array, it can be thought of as a sub array starting at index 2 and going to the last element of the array $#array is the last index of @array

Ok, so you have the individual records in the @data array.

You now need to split the records and check that any of the values in the resultant array with an index > 2 are not equal to zero. If there are print the line.

something like the following is what you are looking for.

use strict; # These two lines use warnings;# will save you grief open (my $data_file, "<", 'test.tsv'); # better to use 3 argument ver +sion of open and to have a lexical filehandle my @data = <$data_file>; # scope your variables close( $data_file); # It's only polite to close up after yourself print $data[0]; # headers for my $line (@data[1..$#data]){ # More perlish not to use indices dir +ectly my @line = split(/\t/, $line); # split the values into an array print $line if (check_for_zero(@line)); # Use a routine to evaluate + the elements } sub check_for_zero{ # declare routine my @line = @_; # get the array we're called with for my $field (@line[2..$#line]){ # again more perlish return 1 if $field != 0; # We have a non-zero value } return 0; #if we got here we never met a non-zero value }
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."