From perlfunc:
-M Script start time minus file modification time, in days.
Note the units: days
You print the integer portion of $diff: int($diff), so unless it has been more than one day since the directory was modified, your result will be 0.
To see that -M is returning a non-zero result, try your program without the int(). You might try the following:
#!/usr/bin/perl use warnings; use strict; my $dirname = "."; opendir(DIR, $dirname) || die "can't opendir $dirname': $!"; my @dots = readdir(DIR); closedir DIR; foreach my $file (@dots){ my $diff = -M $file; print "The age of $file is $diff : " . $diff . " : " . int($diff) +. "\n"; }
In reply to Re: Age of directory
by ig
in thread Age of directory
by sandy1028
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |