while(my $line = <$log>) { # Outer loop. Look for an interesting part of the log file. $n++; $line =~ tr/\r\n//d; ++$TIDCount; ($tid) = $line =~ /tid (\d+)/; print $tid "\n"; $tidc{$tid}++; } print "Thread count for the logfile is $TIDCount\n";