in reply to need helping sorting

Instead of using opendir/closedir, try using Tie::Dir . The keys of the tied hash are the filenames and the values are the results of the file's `stat`.