Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: how to list the files in dir with respect to time

by greenFox (Vicar)
on Aug 02, 2005 at 05:11 UTC ( [id://480080]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://480080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found