D
Dave Saville
I am having problems with Find::File and -M _ in that I get different
values for directories depending on whether I process files or not.
use strict;
use warnings;
use File::Find;
my $d = shift || '';
#print time(), "\n";
$^T=1293201891; # fix basetime to keep numbers the same between runs
find(\¬wanted, '.');
exit;
sub notwanted
{
return if m/^\.$/; # Don't need '.'
return if $d && ! -d; # only directories
print $File::Find::dir,' ',$File::Find::name,' ',$_, ' ', -M _, " ";
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
$mtime, $ctime, $blksize, $blocks) = stat $_;
printf "%20.17f\n", ($^T-$mtime)/86400; # convert mtime to format of
-M
}
File structure:
<somedir>
<dir1>
<dir2>
chdir'ed to <somedir>
[T:\tmp\test]../try.pl
.. ./dir1 dir1 0.00149305555555556 0.00167824074074074
../dir1 ./dir1/stuff1 stuff1 0.00533564814814815 0.00533564814814815
.. ./dir2 dir2 0.00533564814814815 0.00149305555555556
../dir2 ./dir2/stuff2 stuff2 0.00140046296296296 0.00140046296296296
[T:\tmp\test]../try.pl d
.. ./dir1 dir1 0.00167824074074074 0.00167824074074074
.. ./dir2 dir2 0.00149305555555556 0.00149305555555556
It looks as if the -M _ reported for a directory is not the same as
stat'ing it when files are processed. It would appear to have the
mtime of the last processed file. BTW it makes no difference if I use
find() or finddepth().
Or, as usual, am I missing something?
TIA
values for directories depending on whether I process files or not.
use strict;
use warnings;
use File::Find;
my $d = shift || '';
#print time(), "\n";
$^T=1293201891; # fix basetime to keep numbers the same between runs
find(\¬wanted, '.');
exit;
sub notwanted
{
return if m/^\.$/; # Don't need '.'
return if $d && ! -d; # only directories
print $File::Find::dir,' ',$File::Find::name,' ',$_, ' ', -M _, " ";
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
$mtime, $ctime, $blksize, $blocks) = stat $_;
printf "%20.17f\n", ($^T-$mtime)/86400; # convert mtime to format of
-M
}
File structure:
<somedir>
<dir1>
<dir2>
chdir'ed to <somedir>
[T:\tmp\test]../try.pl
.. ./dir1 dir1 0.00149305555555556 0.00167824074074074
../dir1 ./dir1/stuff1 stuff1 0.00533564814814815 0.00533564814814815
.. ./dir2 dir2 0.00533564814814815 0.00149305555555556
../dir2 ./dir2/stuff2 stuff2 0.00140046296296296 0.00140046296296296
[T:\tmp\test]../try.pl d
.. ./dir1 dir1 0.00167824074074074 0.00167824074074074
.. ./dir2 dir2 0.00149305555555556 0.00149305555555556
It looks as if the -M _ reported for a directory is not the same as
stat'ing it when files are processed. It would appear to have the
mtime of the last processed file. BTW it makes no difference if I use
find() or finddepth().
Or, as usual, am I missing something?
TIA