I’m working on a simple Perl script to monitor a log file using the File::Tail module, but I can’t seem to get the module working properly.
The idea is to use it over IRC, but this didn’t seem to work so after tinkering with the interactive interpreter I’ve narrowed the problem down to File::Tail. I’ve cut it down the following basic example to monitor the file and nothing happens at all when new entries are appended to the file:
#!/usr/bin/perl -w
use strict;
use File::Tail;
my $file = File::Tail->new("/var/log/apache2/error.log");
while(defined(my $line = $file->read))
{
print "$line\n";
}
Can anyone suggest what the problem might be? I’ve gone through the perldoc entry and this is virtually copied from there so I can’t really see that I’ve made any glaring errors. I’m running Ubuntu Lucid.
Is it possible that this is a permissions error? Can the user you’re running the script as access
/var/log/apache2/error.log?