I'm having trouble using "$fileAge = -M $fileName" to determine age of files in a directory. Basically, I need to see if all the files in a directory are more than a day old. If they are, I process them. My problem is that whenever the fileAge is printed out, it's null and looks like this:
"
Filename=[result.896] file age = []" I should add that all the files I'm currently scanning are less than a day old for now.
What am I doing wrong?
# Test output files for age to see if they should be processed
# Start out assuming all output files may be parsed
my $filesAreOldEnough = 1;
if ( $numOutputFiles > 0 )
{
foreach my $fileName ( @outputFiles )
{
my $fileAge = -M $fileName;
print "Filename=[ $fileName ] file age = [ $fileAge ]\n";
if ( $fileAge < 1 )
{
$filesAreOldEnough = 0;
#last; # check all files for now
}
}
} else {
# No input files to process, skip directory...
$filesAreOldEnough = 0;
}
edited by ybiC: URL-escaped square brackets in text