Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: efficient way to find most recently modified files?

by mildside (Friar)
on May 08, 2006 at 06:13 UTC ( [id://547961]=note: print w/replies, xml ) Need Help??


in reply to Re^2: efficient way to find most recently modified files?
in thread efficient way to find most recently modified files?

OK, this is untested, but try something like:

my @files_sorted = sort { substr($a,-14,10) cmp substr($b,-14,10) } (g +lob('yourpath/bobby*.txt')); my $latest_file = $files_sorted[-1];

This assumes that all '.txt' files have the name format you mention.

Cheers

mildside

Replies are listed 'Best First'.
Re^4: efficient way to find most recently modified files?
by mildside (Friar) on May 08, 2006 at 06:24 UTC
    Actually, if all your 'bobby*.txt' files follow your filenaming convention then the sort can be expressed a little bit simpler as (untested):

    my @files_sorted = sort (glob('yourpath/bobby*.txt')); my $latest_file = $files_sorted[-1];

    Cheers

    mildside

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-16 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found