Another try....

Here is the logfile I tested on (I´ve marked were the loops starts):
LOGFILE
---------
UNNUMBERED INFO
------------------
#loop1:
Meas.Res. Nr
- value : 248 (fch)
Meas.Res. Nr
- value : 249 (fdh)
Meas.Res. Nr
- value : 250 (feh)
Meas.Res. Nr
- value : 251 (ffh)
Meas.Res. Nr
- value : 253 (fdh)
Meas.Res. Nr
- value : 254 (feh)
Meas.Res. Nr
- value :  (ffh)
------------------
#loop2:
Meas.Res. Nr
- value : 0 (00h)
Meas.Res. Nr
- value : 1 (01h)
Meas.Res. Nr
- value : 2 (02h)
Meas.Res. Nr
- value : 3 (00h)
------------------
#loop3:
Meas.Res. Nr
- value : 1 (01h)
Meas.Res. Nr
- value : 2 (02h)
Meas.Res. Nr
- value : 3 (01h)
Meas.Res. Nr
- value : 4 (02h)
------------------
end of LOGFILE


When I ran the script, the search found: Loop: 1 Value: 0 Loop: 1 Value: 1 Loop: 1 Value: 2 Loop: 1 Value: 3 ... ... Loop: 1 Value: 240 Loop: 1 Value: 241 Loop: 1 Value: 242 Loop: 1 Value: 243 Loop: 1 Value: 244 Loop: 1 Value: 245 Loop: 1 Value: 246 Loop: 1 Value: 247 Loop: 1 Value: 252 Loop: 3 Value: 0

In other words, it missed the absent "255" in the 1st loop, "4" to "255" in the 2nd, "0" in the 3rd and "5" to "255" in the 3rd loop...

/eplabi


From: "Sten Berg" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: Missing sequence finder for logfiles
Date: Fri, 16 Apr 2004 11:04:40 +0200

Sorry John, I realised you ment that your code take care of the lot.
Anyway, I still do get it to work. Execution hangs at the prompt...

/eplabi

From: "Sten Berg" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: Missing sequence finder for logfiles
Date: Fri, 16 Apr 2004 10:48:15 +0200

Hi John (and others)!

So far, I have this code (with good help from Venu :-), and it works:

my $file = shift;
open (TEST, "$file");
my $valcount=0;
my $missvalue = 1;
while (<TEST>)
{
   if(/value : (\d+)/)
   {
           $val = $1;
           $val = $val - 1 if($val> 0);

       if ($valcount != $val)
       {
           $valc = $valcount + 1 ;
           print "\nSequence value $valc to ". $val;
            print " is missing in loop number...\n";
       }
       $valcount=$1;
   }
   $valcount=0 if($valcount==255);
}

Were does your code come in (the loop check)? Does it take care of the special case when/if value 0 is missing?

regards
eplabi







From: "John W. Krahn" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Missing sequence finder for logfiles
Date: Fri, 16 Apr 2004 00:07:33 -0700

Sten Berg wrote:
>
> Hi gurus!

Hello,

> I´m looking for a way of analysing a log file and pinpoint missing sequences
> (foreach loop?). The logfiles looks something like this:
>
> LOGFILE
> - value : 0
> some data...
> - value : 1
> some data...
> - value : 2
> some data...
> ...
> ...
> - value : 255
> some data...
> - value : 0
> some data...
> - value : 1
> some data...
> ...
>
> In other words; one loop stretches from 0-255 and then the next loop starts
> off att 0 again. I just want to know which values that are missing between
> 0-255 AND in which loop they were missing.
>
> I´m greatful if anyone can solve this :-)


This should do what you want:

my ( $loop, $value ) = ( 1, -1 );
while ( <LOGFILE> ) {
    next unless /value : (\d+)/;
    if ( $value >= $1 ) {
        $value = -1;
        ++$loop;
        }
    for ( $value + 1 .. $1 - 1 ) {
        print "Loop: $loop    Value: $_\n";
        }
    $value = $1;
    }



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



_________________________________________________________________ Auktioner: Tjäna en hacka på gamla prylar http://tradera.msn.se


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>



_________________________________________________________________ Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>



_________________________________________________________________
Chat: Ha en fest på Habbo Hotel http://habbohotel.msn.se/habbo/sv/channelizer Checka in här!



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to