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>