How do I loop in Perl?


How to make the loop fall asleep every 100 lines and close / open the log at the specified time?

open(LOGFILE, $logfile) or die "error";
for(;;) {


Here you can use a module to read a file asynchronously like IO :: Async :: FileStream , which allows you to read data added to a file:

This subclass of IO :: Async :: Stream allows reading the end of a regular file which is being appended to by some other process. It invokes the on_read event when more data has been added to the file.

The documentation contains an example that just implements the solution to the described problem.

Scroll to Top