Drieux wrote: > > On Tuesday, July 9, 2002, at 06:25 , John W. Krahn wrote: > [..] > > One way would be to cache the last line read and the next time you read > > the file loop until that line is encountered and only process the lines > > after it. > > john, > > when you say 'cache the last line' - are you meaning > > # > # majik function knows where we cache Stuff > # > my $last_line = get_last_line_from_cach(); > > open(FH, .... ) or die "horrible death"; > > #grovel log till we see the match on $last_line > while(<FH>) { > last if /$last_line/; > } > > # > # now do our new stuff with it, > # but save the 'new' $last_line > # in theory - if there were no new lines, > # this while will not execute... > # > while(<FH>) { > $last_line=$_; > ..... > } > > do_majik_with_db(@arg_list); > > # > # majik funkion hides last line in cache > # > push_into_cache($last_line);
Something like that. :-) But what if the log file has been rotated and the last line is no longer in the file? my $last_line = get_last_line_from_cache(); open LOG, .... or die "$!"; while ( <LOG> ) { rollback_db_data() if $_ eq $last_line; process_db_data(); $last_line = $_ if eof( LOG ); } commit_db_data(); push_into_cache( $last_line ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]