in reply to File::Find and permission error handling

Hello, I tried to implement McA's idea:

use strict; use warnings; use File::Find; use 5.010; # Use current dir of no dir is supplied @ARGV = qw(.) unless @ARGV; my @inaccessible; # Leave out inaccesible top dirs @ARGV = grep { if ( -d $_ and !-r _ ) { push @inaccessible, $_; 0; # don't pass on inaccessible dir } else { 1; } } @ARGV; # Do we have some dirs we can chdir to? unless (@ARGV) { print_report(); exit; } find( { wanted => \&process, preprocess => \&preprocess }, @ARGV ); print_report(); sub process { # do something; } sub preprocess { grep { if ( -d $_ and !-r _ ) { push @inaccessible, "$File::Find::dir/$_"; 0; # don't pass on inaccessible dir } else { 1; } } @_; } sub print_report { say "I couldn't chdir to these directories:"; say "\t$_" for @inaccessible; }

We are what we repeatedly do. Excellence, then, is not an act but a habit. -- Will Durant (Aristotle)