try
sort {(-M $a) <=> (-M $b)}
Update
Imho it is better to use
stat to test the files. -M uses the $^T special variable, which is set once at the start of the script. For long running
scripts this is not recommended. Try this (untested):
#!/usr/bin/perl
use warnings;
use strict;
use File::Copy;
my $srcdir = "\\\\windowsservername\\directory\\Subdirectory\\";
my $dest = "C:\\Documents and Settings\\";
LOOP:
while (1) {
undef $!;
my %fileage = map { ($_ => (stat)[9]) } glob "$srcdir\\*.*";
die "can't glob $srcdir $!" if $!;
my $xmlfile = (sort { $fileage{$a} <=> $fileage{$b} } keys %fileag
+e)[0];
unless (defined $xmlfile){
print "Files have been ended.\n\n";
last LOOP;
}
my $old = "$srcdir/$xmlfile";
move( $old, $dest ) or die "Move $old -> $dest failed: $!";
print
"File Name: $xmlfile moved to Fileshare - 30 mins for next uploa
+d.\n\n";
sleep 1800; # 30 Minutes
}
print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});