use strict; # These two lines use warnings;# will save you grief open (my $data_file, "<", 'test.tsv'); # better to use 3 argument version 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 directly 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 }