On Jul 6, Ryan Frantz said:

I'm working on a script that will generate a listing of files on a
regular basis so that I can create hyperlinks to each respective file.
As you see from the sorted output below, though it is in ASCIIbetical
order, it is not in chronological order:

/2005Jul01-2005Jul02/foo/bar.html
/2005Jul05-2005Jul06/foo/bar.html
/2005Jun09-2005Jun10/foo/bar.html
/2005Jun10-2005Jun11/foo/bar.html
/2005Jun13-2005Jun14/foo/bar.html
/2005Jun14-2005Jun15/foo/bar.html

Is there any decent documentation available that I could study so that I
can sort this better?

I thought about grabbing the ctime of each file and sorting on that but
I'm not sure if that would add unnecessary complexity to the script.

The primary problem is that the dates in the filenames are formatted as "YYYYmmmDD" rather than "YYYYMMDD". Before sorting the filenames, you could convert the month NAMES to numerical representations (Jan => 01, Dec => 12), and then after you've sorted them (ASCIIbetically will work here) you can change those numerical representations back to the month names.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to