Take a look at the updated script above. It's a little easier to read with respect to the stat output (array reference vs. all those undefs).

Also, if you're going to sort, I'd put all the info in an array (of arrays, probably), and then sort on the time. But make sure you don't localtime() it until you print out. It'll be much easier to sort on the raw timestamp (which is just the number of seconds past Unix epoch, as usual) than to try to do it on the munged output-style data.
_________________________
Bitt Faulk