#!/usr/bin/perl # Known issue # If the file gets truncated, the script will not terminate # ============================================================================= use IO::Handle; autoflush STDOUT; use Fcntl qw(:seek); $file = 'mylog.txt'; $started = 0; #set to 1 if you want the file to start reading from the start of the logfile while(1) { open LOG, $file or die "$file could not be opened."; seek LOG, $pos, SEEK_SET if defined $pos; while() { chomp; if($started) { print "$_\n"; } } $pos = tell LOG; close LOG; sleep 1; $started = 1; } exit(0);