Skip Menu |

This queue is for tickets about the File-Tail CPAN distribution.

Report information
The Basics
Id: 107522
Status: open
Priority: 0/
Queue: File-Tail

People
Owner: Nobody in particular
Requestors: HKCLARK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.3
Fixed in: (no value)



Subject: tail => 0 contructor arg not working correctly
If I am reading the documentation correctly, setting the tail constructor arg to zero should have it only look at *new* content in the file. But if I run the example below using v1.3 on Debian linux it immediately matches if the last existing line of the log file already has "new info" in it. In other words, nothing was added to the file but it still matched. Thanks. use File::Tail; my $file = File::Tail->new( name => 'test.log', maxinterval => 1, tail => 0, ); while (defined(my $line=$file->read)) { last if $line =~ /new info/; } say "got match";
The problem is in the inode check on and around line 378, if $oldhandle is defined, $st->ino is checked against an undefined/0 value, the inode has to be saved on the first run Attached is the change that's needed
Subject: tail.diff
--- Tail.pm 2018-05-22 10:43:03.149802345 +0200 +++ ../perl5/lib/perl5/File/Tail.pm 2018-05-22 10:43:36.676959638 +0200 @@ -404,6 +404,7 @@ } else { # This is the first time we are opening this file $st=stat($newhandle); $object->{handle}=$newhandle; + $object->{inode}=$st->ino; $object->position; $object->{lastread}=$st->mtime; # for better estimate on initial read }