sub SERVER_NAME() { 0 } sub DATE() { 1 } # ... sub ERROR_TYPE() { 4 } # etc. while( ) { chomp ; @elements = split /,/ ; if( $elements[ERROR_TYPE] eq 'ERROR' ) { # handle error next ; } } #### use strict ; use Storable ; use FileHandle ; my($hashRef, $log) ; # program startup # read previous data: if( !-e 'myFile' ) { # myFile not found, assume we're starting from the beginning $hashRef->{lastPosition} = 0 ; # start at the beg # add other values as needed } else { $hashRef = retrieve('myFile') ; } $log = new FileHandle('logfile') ; $log->seek($hashRef->{lastPosition}, 0) ; # go back to previous point searched ############# ## Process ## ############# ## ## save where the end of the file currently is, so ## we don't have to scan the whole file again next time ## $hashRef->{lastPosition} = $log->tell() ; # get file offset ## ## Store new state data ## store $hashRef, 'myFile' ;