in reply to Re^3: thread count
in thread thread count

I am sorry but i did not get a clear idea how i should go about it. i have this piece of code which gives me total number of threads but not the unique ones.
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";
i want the count of unique threads not the repeated one. if you can give me an example of this not necessarily my code, then it will be great. I am a novice in perl. Thanks NT

Replies are listed 'Best First'.
Re^5: thread count
by Utilitarian (Vicar) on Jun 10, 2009 at 14:25 UTC
    The keys of the %tids hash are the individual thread ids.
    So add the following after building the hash in your loop
    $tidc=(keys %tidc); print "Number of unique threads referenced is: $tidc\n";
    (keys %tids) is an array of the keys of the hash, assigning an array to a scalar sets it to the number items in the array