in reply to tailing a file without printing its entire contents

If you place the seek, with to-end, above the while loop, it'll skip over the existing content the first time you read the file:

use strict; use warnings; my $logfile = "/var/log/httpd/agent1_access.log"; open(FH,'<',$logfile) || handle_error(); # typical open call for (;;) { seek FH, 0, 2; # this clears the eof flag on FH # eof reached on FH, but wait a second and maybe there will be mor +e output sleep 1; while (<FH>) { print "$_"; } }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: tailing a file without printing its entire contents
by Anonymous Monk on Aug 07, 2014 at 12:17 UTC
    Thanks, exactly what i was looking for!