Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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?
[LanX]: nope this one One day the triangle player of an orchestra gets very ill and goes to the hospital.. ..
[LanX]: don't go to Great Brexitan ... :)

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-10-21 19:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (270 votes). Check out past polls.

    Notices?