
Laurent_R
Veteran
/ Moderator
Oct 9, 2012, 10:55 AM
Views: 4674
|
Re: [GAR] Find last-backup file within a directory using Perl
|
|
|
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)
|