Hello Baryuds, I wrote the following program to try to reproduce your problem, but I wasn't able to. I'd suggest you add a line like this to your program, so you can see just how big a number -M is returning:
print "minus M returns: ", (-M $logfile), "\n";
#!/usr/bin/perl
use strict;
use warnings;
my $logfile = "file.log";
my $internal = 0;
if ($internal)
{
# create a logfile
open LOGFILE, ">$logfile" or die "can't open $logfile: $!";
print LOGFILE "This is a test\n";
close LOGFILE or die "can't close $logfile: $!";
}
else
{
# create logfile externally
system("./write-log");
}
# sleep?
sleep 3;
print "minus M returns: ", (-M $logfile), "\n";
# test modification time
if (-M $logfile > 0)
{
print "The logfile generated by 3rd party script is not new\n";
exit(1);
}
else
{
print "It's a new logfile! Hoooray!\n";
}
__END__