perlquestion
Nitrox
I have a script that needs to determine the oldest file in a particular directory and I'm concerned about the efficiency of my current solution. (This runs every 60 seconds, which is why I'm concerned with optimization). Here's an example snippet:
<p>
<code>
my $dir = ".";
my $file = (sort{(stat $a)[10] <=> (stat $b)[10]}glob "$dir/*.pl")[0];
</code>
<p>
This script runs across multiple platforms (Win32, Solaris, Linux and AIX) so limits me from some perhaps "easier" solutions.
<p>
Another important piece of info is that the directory is relatively small and has no more than 10 files at any given time, so I wasn't concered about the numerous <code>stat</code> calls.
<p>
So is my current solution acceptable, and I'm trying to micro-optimize, or does anyone see a glaring performance issue?
<p>
Thanks in advance for feedback!
<p>
-Nitrox