in reply to Quickest way to get the oldest file
my $file; opendir(DIR, $dir) or die "Can't read $dir: $!"; $file = readdir(DIR) until $file =~ /^[^.]/; print "First file is $file\n"; closedir DIR;
This should be pretty fast and memory efficient, since it doesn't actually read the whole directory. Of course, it won't work if the files in the directory can be modified after being placed there, as the oldest file will no longer be the first.
-- zigdon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (z) Re: Quickest way to get the oldest file
by mr_mischief (Monsignor) on Jan 23, 2004 at 15:00 UTC |