Title: Message
I've removed the unnecessary foreach loop and the $line variable.  I'm assuming that 2152 OUTLOOK.exe is at the beginning of a line.
 
The trick is to use the capturing capability of the regex.
 
        $pid = '00000';  # invalid PID
        while (<DRWTSN>) {   
            if (($pid) = /App\:.+pid=(\d+)/) {
                print  "<b>$_</b><br>";
            }
            if (/^$pid\s/) {
                print "$_<br>";
            }
            if (/When\:/) {
                print "$_<br>";
            }
            if (/Exception\Snumber\:/) {
                print "$_<br><br><br>";
            }
          }  
Gary
-----Original Message-----
From: Nikko Odiseos [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 03, 2001 11:33 AM
To: [EMAIL PROTECTED]
Subject: Parsing pids from drwtsn.log

I am trying to parse the dr watson log and trying to get it so that when it fines the pid that generated an exception it looks from that place in the log and looks for the next instance of the pid string and prints it out. 
 
Right now it prints out this:
App: mmc.exe (pid=2152)
When: 11/28/2001 @ 11:42:46.513
 
But I want it to print out this:
App: mmc.exe (pid=2152)
2152 OUTLOOK.exe
When: 11/28/2001 @ 11:42:46.513
 
What I have so far is this:
 
$drwt = "C:/Documents and Settings/All Users.WINNT/Documents/DrWatson/drwtsn32.log";
print  "<a name=\"drwatson\"></a><br>";
print   "<b>Dr Watson Log</b><br>";
if (-e $drwt) {
     open (DRWTSN, $drwt) ;
        while (<DRWTSN>) {   
        foreach $line (<DRWTSN>) {
               if ($line =~ /App\:/) {
               print  "<b>$line</b><br>";
               }
               if ($line =~ /When\:/) {
                print "$line<br>";
               }
               if ($line =~ /Exception\Snumber\:/) {
                print "$line<br><br><br>";
               }
          }  

 close DRWTSN;
 }
else {
print  "No Dr Watson Log in All Users.WINNT\Documents\DrWatson";
}
Thanks for any help!

Reply via email to