$firstrun = 1; while(1) { if ( -s $file ) { sleep 1; open(TF,$file) || next ; seek(TF,0,0); @lines=; my $curpos=tell(TF); close(TF); if ( $firstrun < 1 ){ foreach $lyne (@lines){ printf $lyne; } } sleep 1; $firstrun = 0; while(-s $file ) { open(TF,$file) || last ; seek(TF,$curpos,0); @lines=; $curpos = tell(TF); last if ((stat(_))[7] < $curpos); foreach $lyne (@lines){ printf $lyne; } close(TF); sleep 1; } } else { sleep 5; } } #### while (1) { stat the file if size of file changed since last time { open file seek to previous EOF print file contents until EOF save EOF position for next time close the file } sleep for x seconds }