23skiddoo has asked for the wisdom of the Perl Monks concerning the following question:

I am using File::Find to recursively search a set of directories, but I want to suppress errors--such as when I don't have permission to chdir() to a particular directory. By the time I'm processing the files/dirs with the subroutine, it's too late to test them.

Or do I need to roll my own?

Thanks!

Originally posted as a Categorized Question.

  • Comment on How can I make File::Find skip over dirs to which I don't have permission?

Replies are listed 'Best First'.
Re: How can I make File::Find skip over dirs to which I don't have permission?
by fundflow (Chaplain) on Aug 31, 2000 at 02:01 UTC
    Did you try -r -x ?

      OK, I'm getting the hang of this format--I guess instead of a preview per se, I have a lag time for editing....

      Anyway, in regards to using -r -x (or other tests), that will keep me from churning them through the subroutine, like so:

      find ( \&procfile, @DIRS ); sub procfile { return if ! -r -x; # do something to everything else here }
      But I am wondering how to keep Find::File from attempting to enter unpermitted subdirectories before they get processed by the subroutine.

      Prost!

      > (My apologies if I've munged the HTML. I'm new to Perl Monks and wish there were a preview option for submissions a la slashdot.) OK, I just RTFM. I see now. (I like to dive right in... :) ) Prost!