in reply to how to run a specific file from a list of filenames in a folder

You are sorting the files of @filenames according to their last modification dates. And it seems to be doing that correctly (although you don't need to insert $a and $b between double quote marks, but that should still work correctly). Is this what you want? Please tell us in which respect your code does not satisfy your needs. Are you sure that the @filenames array is populated correctly before this part of your code starts to run? Perhaps you could print its content to check that.

Also, please, use <code> and </code> tags for your code and data samples, in order to preserve their format.