Sten Berg wrote:
> 
> 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


This was tested on the supplied data and appears to work correctly:

use constant RANGE_START => 0;
use constant RANGE_STOP  => 255;

my ( $loop, $old_value ) = ( 1, RANGE_START - 1 );

while ( <DATA> ) {
    ( my $curr_value ) = eof DATA ? ( RANGE_STOP + 1 ) : /^- value : (\d+)/ or next;
    if ( $old_value >= $curr_value ) {
        print "Loop: $loop    Value: $_\n" for $old_value + 1 .. RANGE_STOP;
        $old_value = RANGE_START - 1;
        ++$loop;
        }
    print "Loop: $loop    Value: $_\n" for $old_value + 1 .. $curr_value - 1;
    $old_value = $curr_value;
    }



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>


Reply via email to