bwelch has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using -M to test age of file
by VSarkiss (Monsignor) on Aug 22, 2003 at 15:23 UTC | |
Re: Using -M to test age of file
by tachyon (Chancellor) on Aug 22, 2003 at 15:23 UTC | |
Re: Using -M to test age of file
by arthas (Hermit) on Aug 22, 2003 at 15:29 UTC | |
Re: Using -M to test age of file
by bwelch (Curate) on Aug 22, 2003 at 16:46 UTC | |
Re: Using -M to test age of file
by tcf22 (Priest) on Aug 22, 2003 at 15:17 UTC | |
by tachyon (Chancellor) on Aug 22, 2003 at 15:30 UTC | |
by sauoq (Abbot) on Aug 22, 2003 at 17:07 UTC |
Back to
Seekers of Perl Wisdom