note
ehdonhon
<P>The thing with -M is that it measures the age of the files, in days since $^T, which is initially set by perl to the epoch time when your program started. When you are running in mod_perl, don't expect $^T to be anywhere near the the present time, because it will be set to the time when your apache child started up.</P>
<P>If you want to make sure that -M always returns a positive value <i>(for all files created in the past)</i>, you need to do something like this:<br>
<code>
$^T = time();
my $fileage = -M $filename;
</code>
<P>However, in your case, it looks like all you care about is finding the oldest file in a list of files. That can be achieved easy enough:<br>
<code>
my ($oldest_file) = sort { -M $b <=> -M $a } @filenames;
</code>
<P><font size="-1"><b>Update:</b> [merlyn] correctly pointed out that setting $^T does not guarantee a positive return value for -M when the datestamp on a file is set to some time in the future.</font></P>
348400
348400