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

    Thank you for this update: I was struggling with this syntax along with having a large reading burden to get into the whole pod scheme. I see now that it can be incremental, as pod is somehow syntactic perl. I had to wade through File::Find.pm just like they tell you to as well as WWW::Mechanize.pm, which I found astonishing under this view. I had never understood all this **clutter** in these modules that couldn't be perl, at least because it lacked semi-colons. So, yeah, light bulb, there.

    Maybe the castaways leave the coast when they get a pause account, define a local::lib, and declare their real intent to make a didactic effort at the material of gilligan's island.

    The castaways are logging their misadventures now:

    C:\Users\Fred\Documents>perldoc g7.pl DESCRIPTION This is a pretty good first attempt at figuring out where your mod +ules are. It is meant to follow the development of _Intermediate Perl_, + and I will adhere to the idioms. C:\Users\Fred\Documents>

    This is how I figured out what has been happening since the 16 days I've had a local::lib :

    #!/usr/bin/perl use warnings; use strict; use File::Find; use Cwd; =pod =head1 DESCRIPTION This is a pretty good first attempt at figuring out where your modules + are. It is meant to follow the development of _Intermediate Perl_, a +nd I will adhere to the idioms. =cut my $current = cwd; find( \&pm_beneath, $current, ); sub pm_beneath { use File::Basename; my $basename = basename($File::Find::name); return unless $basename =~ /\.pm$/; print "$File::Find::name\n"; my $access_age = -A $basename; print " $basename\n"; print "access age in days: $access_age\n\n"; } __END__

    Output for readmore tags. It's 300 lines of the Minnow being tossed:

      So, if this dir was made 16 days ago, all of the .pm files are being used - some more often than others.

      To reduce the "noise" in the printout, you can truncate the "Access Age in Days" with a printf statement:

      my $x = '3.30043981481481'; printf "%.2f\n", $x; #prints 3.30, 2 decimal places