Mike Singleton wrote:
> How would I go about identifying and selecting the most recent file (based on
>creation date?) in a directory??
In a given directory ? opendir/readdir/closedir - stat each file and save
the filename and mtime if it's higher than the currently saved value.
Untested:
use strict;
my $saved_mtime = 0;
my $saved_file = '';
opendir DIR, $dir or die $!;
while (my $file = readdir DIR) {
my $mtime = (stat "$dir/$file")[9];
if ($mtime > $saved_mtime) {
$saved_file = $file;
$saved_mtime = $mtime;
}
}
closedir DIR;
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs