G
g4173c
Greeting:
I have the following code to sort an array of dirs/files:
@sorted = sort { -M $b <=> -M $a } @logfile;
foreach $lastfilemod (@sorted) {
$dir = (dirname $lastfilemod);
if (! exists $srt{$dir} ) {
push(@srtlist, $lastfilemod);
$srt{$dir} = 1;
}
}
The @logfile looks like:
/dir/dir/file1
/dir/dir/file2
/dir/dir2/file1
....
What I was trying to do is have @sorted list the files by last
modified and then I could print out each file last modified in one per
directory. However the sort isn't working correctly and I'm not
getting the last file modified for some directories. Could anyone
point out what I'm doing wrong?
Thanks in advance for any help!
Tom
I have the following code to sort an array of dirs/files:
@sorted = sort { -M $b <=> -M $a } @logfile;
foreach $lastfilemod (@sorted) {
$dir = (dirname $lastfilemod);
if (! exists $srt{$dir} ) {
push(@srtlist, $lastfilemod);
$srt{$dir} = 1;
}
}
The @logfile looks like:
/dir/dir/file1
/dir/dir/file2
/dir/dir2/file1
....
What I was trying to do is have @sorted list the files by last
modified and then I could print out each file last modified in one per
directory. However the sort isn't working correctly and I'm not
getting the last file modified for some directories. Could anyone
point out what I'm doing wrong?
Thanks in advance for any help!
Tom