On May 13, 2004, at 6:19 PM, [EMAIL PROTECTED] wrote:
#!/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]; }
Instead of using string-munging, you can use a real data structure:
------------ #!/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], $path];
}@files = map $_->[1], sort {$a->[0] <=> $b->[0]} @files;
print "$_\n" foreach @files; ------------
-Ken
