in reply to Re^2: using File::Find to find recently-installed modules
in thread using File::Find to find recently-installed modules
That neither a,c nor m time for the unix installed modules exists knocks my socks off and, along with the sea forward and backslashes, makes me believe that my logic is faulty.
The issue is that you have a relative path, the '.' File::Find does a cd as it navigates downwards. By the time you do the file test, you are not where you think you are and the file test fails. Since you are actually "in the directory", you can use the simple name of the file, eg. just "Timeout.pm". File::Basename can get that from $File::Find::name. The branch which started with an absolute path name works fine because it doesn't matter what directory that you are in when you do the stat.
update: It is not necessary to use "\" on Windows. The "/" will work just fine. That is also true from the command line. The "\" is a hold over from DOS days and causes obvious problems due to its special meaning in Perl.
Also worthy of note are side effects of this changing working directory business. If you code something that could "blow up" in Find, you will be left in some random part of the directory tree.
Update: Here is some code to demo what I've said. I started in the ".." directory and used basename($File::Find::name) to do a simple file test on the basename.
#!/usr/bin/perl use warnings; use strict; use File::Find; use File::Basename; find (\&for_every_name,'..',); sub for_every_name { my $basename = basename($File::Find::name); return unless $basename =~ /\.pl$/; print "$File::Find::name\n"; my $access_age = -A $basename; print " $basename, acccess age in days: $access_age\n"; } __END__ Abridged output: ../SSPH_Results/cmpN1MMarrlresults.pl cmpN1MMarrlresults.pl, acccess age in days: 40.9642361111111 ../SSPH_Results/convert2oldCSV.pl convert2oldCSV.pl, acccess age in days: 17.5422685185185 .....deleted..... ../testing/FileFinder.pl FileFinder.pl, acccess age in days: 1.15740740740741e-005 Note: *** "FileFinder.pl" is the name of this file, hence the Note: *** very short last access time! ../testing/fileFindexample.pl fileFindexample.pl, acccess age in days: 0.110034722222222
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: using File::Find to find recently-installed modules
by Aldebaran (Curate) on Jun 28, 2016 at 10:39 UTC | |
by Marshall (Canon) on Jun 28, 2016 at 23:44 UTC |