in reply to Re^2: File::Tail issue..
in thread File::Tail issue..

Searching the docs for "timeout" found a solution.

# Check for new File::Tail object every $timeout seconds. my $timeout = 60; for (;;) { my (undef, undef, @pending) = File::Tail::select(undef, undef, undef, $timeout, $file); for (@pending) { my $line = $_->read(); print $line; } }

Update: You could even simplify your signal handler (always a good thing) and your code in general as follows:

use File::Tail; # Check for new File::Tail object every $timeout seconds. my $timeout = 60; my $qfn = $ARGV[0]; my $new = 1; my $changed = 0; my $tail; $SIG{INT} = sub { $changed = 1 }; for (;;) { if ($changed) { $changed = 0; open(my $fh, '<', '/tmp/filename') or die("Cannot open file: $!\n"); chomp( $qfn = <$fh> ); $new = 1; } if ($new) { $new = 0; $tail = File::Tail->new( name => $qfn, maxinterval => 3, adjustafter => 2, tail => -1, ); } my (undef, undef, @pending) = File::Tail::select(undef, undef, undef, $timeout, $tail); for (@pending) { my $line = $_->read(); print $line; } }

Replies are listed 'Best First'.
Re^4: File::Tail issue..
by Anonymous Monk on Mar 20, 2009 at 21:08 UTC
    Thanks ikegami. That worked neat. But I'm still wary of this disclaimer in the docs:

    "Note: Select functionality was added in version 0.9, and it required some reworking of all routines. ***PLEASE*** let me know if you see anything strange happening."
    Anyways thanks for helping me out. I'm going forward with this :)
      All routines had to be reworked, so if you're using a version that's been released since Nov 1998 (over a decade ago), you're affected by this whether you use select or not.