in reply to File::Tail issue..

I don't think your $file is getting reassigned in the loop which is why you don't get the subsequent file's after the first.

Try something like (untested):

use File::Tail; my $cur_filename $SIG{'INT'} = sub { if (-e ($cur_filename = "/tmp/filename")) { $NEWFILE = 1 } else { die "Cannot open file:$!" } }; $cur_filename=$ARGV[0]; while (1) { my $file=File::Tail->new(name => $cur_filename, maxinterval => 3, adjustafter => 2, tail => -1); while (defined($line=$file->read)) { print $line; last if $NEWFILE; } $NEWFILE = 0 }

Replies are listed 'Best First'.
Re^2: File::Tail issue..
by kennethk (Abbot) on Mar 20, 2009 at 15:05 UTC

    I'm pretty sure scoping is not the issue (I thought this at first), because the following code works as expected:

    $SIG{'INT'} = 'Int_Handler'; sub Int_Handler { $file = 2; }; $| = 1; $file = 1; while ($file) { print $file; $file = $file == 1 ? 1 : 0; sleep(1); }

    While the OP should probably adhere to strictures (and is doing a lot of work inside a signal handler), this is not the issue.