in reply to -M file test operator
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__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: -M file test operator
by bayruds (Acolyte) on Jul 29, 2004 at 01:42 UTC | |
by beable (Friar) on Jul 29, 2004 at 06:04 UTC |