in reply to Re^2: Getting modification time in perl not working on my MAC
in thread Getting modification time in perl not working on my MAC

Though, with all the variables correct, it is still not working. -M command is working if it is between the opendir and closedir lines

Well you have  -M $moviedir[1] and  -M "$CosMovFolder/$moviedir[1]" its the basic stumbling block of readdir that everyone stumbles on .

readdir is just low level api ... low level api are a pain

use Path::Tiny its easy

use Path::Tiny qw/ path /; my @sorted_files = map { $$_[1] } sort { $$a[0] <=> $$b[0] } map { [ $_->stat->mtime, $_ ] } path( $CosMovFolder )->realpath->children();