Forum Moderators: coopster
I need to use Perl to sort a directory and sort the files in order of date. I know there is a date stamp because when I do an "ls" or view the files in my ftp viewer, there are dates like 4/3/03.
However, I can't figure out how to access it from Perl. I tried using:
(stat($gallerypath . $b)) [9] <=> (stat($gallerypath . $a)) [9]
As my sort function, but it only uses the timestamp which is NOT the date. How do I access the date to sort on?
HELP! :)
I don't see anything wrong with your syntax of
(stat($gallerypath . $b))[9]
Perhaps approach it by divide and conquer. i.e. put debug statements in such as:
print (stat($gallerypath . $b)) [9], "\n";
(stat($gallerypath . $b))[9] returns the time in seconds since 1 Jan 1970, hence includes the full date, not just the time. Possibly the problem is somewhere else in your sort routine?
Note:
(stat($gallerypath . $b))[9] returns the time of last mod
(stat($gallerypath . $b))[10] returns the time of creation
Shawn