Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to find most recent file and use it?

by johngg (Abbot)
on May 25, 2012 at 14:54 UTC ( #972452=note: print w/ replies, xml ) Need Help??


in reply to How to find most recent file and use it?

Something like this perhaps?

... use List::Util qw{ max }; ... my %filesByAge = map { ( stat $_ )[ 9 ], $_ } glob q{*.rtf}; my $mostRecent = $filesByAge{ max keys %filesByAge }; ...

It might not pick the particular file you want if you have a lot of RTFs created at exactly the same time but that sounds unlikely.

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: How to find most recent file and use it?
Download Code
Re^2: How to find most recent file and use it?
by luxlunae (Novice) on May 25, 2012 at 15:10 UTC
    That did work, using
    open INPUT, "<$mostrecent"; after the code that you supplied!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2015-07-06 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls