Here's an example of what I mean by "reduce the problem to 5-25 lines of code". The portion of the code you're having trouble with could be reduced to the following test:
use strict;
use warnings;
use File::Tail;
use POSIX ();
my $filename = POSIX::strftime('ServerLog(%m-%d-%Y).log', localtime );
print "\$filename = <<<$filename>>>\n";
my $log = "D:\\ServerTools\\Logs\\$filename";
print "\$log = <<<$log>>>\n";
my $file = File::Tail->new($log);
while( defined( my $line = $log->read ) ) {
print "\$line = <<<$line>>>\n";
}
unlink $log or die $!;
And then it would become quite clear to see that $log contains a file path. A file path is not a File::Tail object. Your File::Tail object is referred to by $file. Therefore, if you want to invoke the read method on your File::Tail object, you should be invoking it as:
while( defined( my $line = $file->read ) ) { ...
It's pretty obvious that the database stuff wasn't the problem you're asking about. So as you're trying to nail down what the issue is by creating some test code, you can immediately eliminate it. Eliminating that, and any other unrelated code-noise, you're left with just the problem, and it becomes easier to see. I hope this exercise is helpful to you.
|