Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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.



Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://972452]
WinnieB bows, falls over, and tries to stand up again
[marto]: at least gravity is still working
[Discipulus]: welcome WinnieB, good morning marto

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-03-30 06:53 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (353 votes). Check out past polls.