If you are using readdir then you have to prepend the directory name to the file name when you do the stat, for example:
opendir DH, $dir or die "Cannot opendir '$dir' $!"; my @filelist = readdir DH; my @sorted = sort by_last_mod @filelist; sub by_last_mod { my $adate = ( stat "$dir/$a" )[ 9 ]; my $bdate = ( stat "$dir/$b" )[ 9 ]; return $adate <=> $bdate; }
In reply to Re^3: Sorted by date file not working?!
by jwkrahn
in thread Sorted by date file not working?!
by natol44
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |