in reply to Skipping unreadable directories with File::Find

I think you are missing something on your end.

I created a directory, relative to this script:

use strict; use warnings; use File::Find; &find(\&wanted, 'find_tmp'); sub wanted { /^foo$/ && print("$_\n"); }
I create the directory find_tmp and three directories inside of it -- each one contained two touched files, foo and bar. I set the permissions of one of those directories to 000 and ran the script:
[jeffa@server1 perl]$ ./foo.pl
foo
Can't cd to (find_tmp/) cannot: Permission denied
 at ./foo.pl line 9
foo
Looks like File::Find is indeed skipping directories as advertised -- that is, it is not die'ing when it cannot access them due to permissions. (Are you really sure you have the proper permissions?) If you redirect STDERR, you won't get the warning messages:
[jeffa@server1 perl]$ ./foo.pl 2>/dev/null
foo
foo

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re: Skipping unreadable directories with File::Find (or how to test your code)
  • Download Code

Replies are listed 'Best First'.
Re^2: Skipping unreadable directories with File::Find (or how to test your code)
by opensourcer (Monk) on May 27, 2005 at 05:43 UTC
    ya i noticed "}" at the end of the sub routine, but i need a way to look up into the folder where i have read, execute access, other wise there is no meaning of me writing a code for searching files or folders, i have tried on every folder on my linux box, the code works fine only on my home folder, and fails on other folder inside "/" on whom i have read, excute and even write on some folder and files.

    "I really don't live on earth, it's just my reflection" "open source is not only technology, but it's a world out there - opensourcer"