CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [GAR] Find last-backup file within a directory using Perl: Edit Log



Laurent_R
Enthusiast / Moderator

Oct 9, 2012, 10:55 AM


Views: 1688
Re: [GAR] Find last-backup file within a directory using Perl

 

Code
foreach (sort keys %files) { 
# the previous line iterates over the unique file names in the hash %files. Each name is stored
# in the $_ special variable
my @files_latest = glob("$_*");
# the previous line looks in the directory for files having each of the unique file names
#and stores the result in the @files_latest array
print "$files_latest[$#files_latest]\n";
# this prints the last element of the @files_latest array, i.e. the most recent backup



(This post was edited by Laurent_R on Oct 9, 2012, 10:58 AM)


Edit Log:
Post edited by Laurent_R (Enthusiast) on Oct 9, 2012, 10:58 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives