my $lineCount = 0; foreach my $file (@whiFiles) { print "reading $file\n"; my $HANDLE = new IO::Uncompress::AnyUncompress($file,Transparent => 1, AutoClose=>1) or die; while (<$HANDLE>) { next if ($_ =~ /^#/); chomp; my ($chr, $pos, $codes) = split(/\t/, $_); $lineCount++; } close $HANDLE; } print "Line count is $lineCount\n";