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

DWIM is Perl's answer to Gödel

In reply to Re: File::Tail on win32 by GrandFather
in thread File::Tail on win32 by perlAffen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.