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>




Reply via email to