Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Delete all but the most recent backup file

by kielstirling (Scribe)
on Jan 24, 2013 at 04:44 UTC ( #1015073=note: print w/ replies, xml ) Need Help??


in reply to Delete all but the most recent backup file

Hey, Not sure if I understand the question ... but, this will give you the last modified file.
#!/usr/bin/perl use Modern::Perl; use IO::Dir; my $path = shift; my $dir = IO::Dir->new($path); my %files; for my $file (grep !/^\./, $dir->read) { $files{$file} = (stat("$path/$file"))[9]; } my $file = (sort {$files{$a} <=> $files{$b}} keys %files)[0]; say "$file ", scalar localtime($files{$file}); undef $dir;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2016-07-02 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (19 votes). Check out past polls.