Seek the wisdom of the Perl Monks at www.perlmonks.org.
Short answer: http://perldoc.perl.org/functions/-X.html
-M gives the file age.
--John
Tara taralish-at-yahoo.com |Perl 6| wrote:
I'm trying to do a Perl script (PC has Perl5 installed) in a BAT file
which will open the CMD prompt, interact with the user and copy files
from one location to other directories. Does anyone know how to "dir"
the files in a directory into an array and sort by date and return the
ones within the past week? So far I have this code and it returns all
the files:
@files = `dir`;
chomp (@files);
print "$#files \n";
if ( @files =~ /[Qq]/ ) {
exit 0;
}
if ( @files =~ /xml$/ ) {
print "Recently added XML files: $files \n";
printf COPYLOG "Recently added XML files: @files \n";
$type = "xml";
}
elsif ( @files =~ /tc$/ ) {
print "You are copying an expected result file \n" ;
printf COPYLOG "You are copying an expected result file \n" ;
$type = "tc";
}
else {
print "Invalid file type or @files doesn't exist in current
directory\n" ;
printf COPYLOG "Invalid file type or @files doesn't exist in
current directory\n" ;
$type = "bad";
}