my $lineCount = 0; foreach my $file (@whiFiles) { print "reading $file\n"; open IN, "gunzip -c $file |" or die "Can't open file $!"; while () { next if ($_ =~ /^#/); chomp; my ($chr, $pos, $codes) = split(/\t/, $_); $lineCount++; } close IN; } print "Line count is $lineCount\n";