in reply to Re^2: Sorted by date file not working?!
in thread Sorted by date file not working?!

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; }