in reply to RE: Re: Advanced Sorting
in thread Advanced Sorting

1. read the perlman (or unixman) for the commands stat() and sort()
2. try to understand the following :-)
sub bydate{(stat $dir.$a)[9]<=>(stat $dir.$b)[9];} @sortedfiles = sort bydate @files_in_your_dir;
Have a nice day
All decision is left to your taste
Update
ok, I might have been wrong when assuming that logs get analyzed but not changed, after they have been archived

Replies are listed 'Best First'.
RE: RE: RE: Re: Advanced Sorting
by merlyn (Sage) on Oct 28, 2000 at 20:06 UTC
      #!/usr/local/bin/perl use strict; $|++; my $dir = "../../logs/"; my $output = "../stats/current.txt"; #read the dir and put all files to a list opendir DIR, $dir || die "blah!"; my @allfiles = readdir DIR; close DIR; # remove those files from list that don't seem to be logfiles my @logs = grep /^\d{6}.?\.log$/i, @allfiles; # sort in a way you like my @sorted = map{ $_->[0] } sort {$a->[1] cmp $b->[1]} map { [ substr($_,2,2).substr($_,0,2).substr($_,4)] } @logs; # start output open OUTPUT, ">$output" || die "blah!"; print OUTPUT join "\n", @logs; close OUTPUT; # end output