Should be $directory\\$file.
Incidentally, you might try doing this if you have a huge number of files:
Code:
%h = map(($_, -M "$directory\\$_"), @files);
@files = sort { $h{$a} <=> $h{$b} } @files;
Hitting stat (or the Win32 equivalent) is fairly expensive. You could make it even faster by rolling the -M values into the keys and using straight sort(@files), but that's often overkill.