Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

retrieve file with latest date stamp

by mark4444az (Sexton)
on Apr 15, 2011 at 21:47 UTC ( [id://899688]=perlquestion: print w/replies, xml ) Need Help??

mark4444az has asked for the wisdom of the Perl Monks concerning the following question:

I am using File::Find to sort through a directory. It works, but the problem is I only want to print the latest file name. how would you do that?

Replies are listed 'Best First'.
Re: retrieve file with latest date stamp
by kennethk (Abbot) on Apr 15, 2011 at 21:54 UTC
    The -M function will return the "Script start time minus file modification time, in days." You will need to keep track of which one has the smallest value yourself, and then output the result outside of your find routine.
Re: retrieve file with latest date stamp
by JavaFan (Canon) on Apr 15, 2011 at 22:17 UTC
    I'd use:
    my $last_modified = (`ls -t`)[0];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found