perl File::Tail delay

I'm using the perl File::Tail library to tail the output of a file and parse it's output.

Everything's working fine except there seems to be about a 10 second delay after I start the script before it starts outputting. After the first read, it works fine and all output is instantaneous. All of the writes during the delay seem to be outputted once it starts working, so I'm not losing any data. I don't think it has nothing to do with the file I'm reading because running a regular "tail -f" works instantly.

Heres the entire script:

#!/bin/perl
use File::Tail;

$file=File::Tail->new("file.txt");

while (defined($line=$file->read)) {
    print "$line\n";
}

I copied this from an example somewhere online. I'm not very familiar with perl or File::Tail I'm hoping I'm doing something wrong. Any help would be appreciated.

Answers


See the interval option in the documentation:

The initial number of seconds (real number) that will be spent sleeping, before the file is first checked. Default is ten seconds, meaning "File::Tail" will sleep for 10 seconds and then determine, how many new lines have appeared in the file.


Need Your Help

boost::spirit permutations

c++ boost boost-spirit boost-spirit-qi

I have to parse the following piece of text

Socket accept is consuming my memory on windows without release

c windows sockets gcc memory-management

I have written a very small function in C, opens a socket, accepts connection and immediately closes them.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.