Hello,

I'm still extremely new to Perl, and was wondering if some
of you might mind taking a peek at the code below and
telling me if there's anything that could make it better or
more efficient?

The code below is my attempt at grabbing the files from a
folder and then sorting them by modification date.

Thanks for your insight.

Jay

-----

#!/usr/bin/perl

my $dir = "/Users/jay/Desktop/Other Stuff/old stuff 4";

opendir FOLDER, $dir or die "Cannot open $dir: $!";

foreach $file (readdir FOLDER) {
   next if $file =~ /^\./;
   $path = "$dir/$file"; 
   next unless -f $path and -r $path;   
   push @files, (stat $path)[9].chr(1).$path."\n";
}

@files = sort @files;

foreach (@files) {
   push @sortedList, (split(chr(1), $_))[1];
}

print @sortedList;

Reply via email to