in reply to how to list the files in dir with respect to time
If all you want is the very latest file then a straight out compare as you traverse the file list will do...
my $latest; $latest->{mtime} = 0; for (glob '/path/to/logs/*.log' ) { next if -d; my $mtime = (stat)[9]; if ($mtime > $latest->{mtime}){ $latest->{filename} = $_; $latest->{mtime} = $mtime; } } print $latest->{filename}, "\n";
Update: I see sk already posted this...
--
Murray Barton
Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho
|
|---|