THe following sample code should do it for you. You should omit the updateFile related code - that's just there to get the test file updated.
use strict; use warnings; my $logFileName = 'test.txt'; my $lastPos = 0; my $endTime = time + 60; while (time < $endTime) { next if ! -e $logFileName; next if $lastPos >= -s $logFileName; open inFile, '<', $logFileName; seek inFile, $lastPos, 0; print while <inFile>; $lastPos = tell inFile; close inFile; } continue { sleep (5); updateFile (); } sub updateFile { open outFile, '>>', $logFileName; print outFile 'Line added to file at ' . (join ', ', localtime) . "\n" +; close outFile; }
Printed:
Line added to file at 30, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 35, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 40, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 45, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 50, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 55, 16, 12, 30, 10, 105, 3, 333, 1 Line added to file at 0, 17, 12, 30, 10, 105, 3, 333, 1 Line added to file at 5, 17, 12, 30, 10, 105, 3, 333, 1 Line added to file at 10, 17, 12, 30, 10, 105, 3, 333, 1 Line added to file at 15, 17, 12, 30, 10, 105, 3, 333, 1 Line added to file at 20, 17, 12, 30, 10, 105, 3, 333, 1
In reply to Re: File::Tail on win32
by GrandFather
in thread File::Tail on win32
by perlAffen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |