Here's a possible solution. It involves storing the ending line number from the last six passes in a temp file. I'll leave the coding to you.
- First read in the line counts from the temp file into @linecounts.
- Get the starting point: $start = shift @linecounts
- On the pass through the log file iterate directly to the starting point: for (0..$start) {<FH>}.
- From there start parsing dates and log entries while incrementing $start with each line.
- Do whatever if entries found/not found
- Add new line count to array: push (@linecounts, $start)
- Rewrite temp file from @linecounts.
- Repeat in 5 minutes