What does the no_chdir => 1 mean?
from File::Find manual:
"no_chdir"
Does not "chdir()" to each directory as it recurses. The wanted()
function will need to be aware of this, of course. In this case, $_
will be the same as $File::Find::name.
In other words, it just means that your program will skip the chdir part which is useless for your program (so you gain again some CPU cycles) and, as a bonus, $File::Find::name equals $_, so you'll be able to use:
push @{$files{$name}}, [ $_, $size, int -A _ ];
instead
push @{$files{$name}}, [ $File::Find::name, $size, int -A _ ];
What is the purpose of Cache::MemoryCache?
heh, i told you in my previous post to consider using getpwuid and a caching system instead of pushing all users information into memory. Cache::MemoryCache is just a wellknown module that could be useful for such things.
OFC, it your specific case, this could be overworking as your program is too simple and maybe a simple hash cache would be enough. Anyway, I was trying to prepare you for more complicate stuff ;-)
What is being cached? The correspondance between UserIDs and UserNames.
Let's see an example using a simple hash-cache.
my %cache;
find({wanted => \&ab_wanted, no_chdir => 1}, $opt{d});
use Data::Dumper;
print Dumper \%files, \%cache;
sub ab_wanted {
if (-r _ && -f _){
$size = int ((-s _) / 2**20);
if ($size > $opt{s} && $opt{a} < -A _){
$uid = (lstat(_))[4];
my $name = $cache{$uid};
unless (defined $name) {
$name = getpwuid($uid);
$cache{$uid} = $name;
}
push @{$files{$name}}, [ $_, $size, int -A _ ];
}
}
}
| [reply] [d/l] [select] |