in reply to Age of directory
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Age of directory
by sandy1028 (Sexton) on Mar 18, 2009 at 04:25 UTC | |
by ig (Vicar) on Mar 20, 2009 at 00:01 UTC |