2012-06-01 16:04:46,395 Thread-12796 - Dispatcher thread #1 INFO JMasterProtocol - JMasterProtocol.getMasterPushExitInstance: Asked exit instance for target 'SPF293R' from dispatcher #### use strict; use warnings; use diagnostics; my $searchfor = shift @ARGV or die "Please specify the search target as an argument"; my (%TargetList, $linecount, @foundThreads); my $logName = 'test-logfile.txt'; open my $logIn, '<', $logName or die "Can't open $logName: $!\n"; while (defined (my $line = <$logIn>)) { $linecount++; my ($thread, $target) = $line=~m/Thread-(\d+).+target\s*'([^']+)'/ or next; push @{ $TargetList{$thread} }, $target; if ($target eq $searchfor){ push @foundThreads, $thread; } } close $logIn; if (scalar(@foundThreads)>0){ print "Target '$searchfor' is in threads " . join(",",@foundThreads), "\n"; print "Targets in these threads are:\n"; for my $t(sort @foundThreads){ print " $t: $_\n" for @{$TargetList{$t}}; } }else{ print "*** Target '$searchfor' was not found in log $logName\n"; } print "Totals: $linecount lines, ",scalar(keys %TargetList)," Threads.\n";