There are three possible actions
It seems to me that your cases are
if ( $fs eq '/' ) { # only if the root directory my_find( $fs, 0 ); } elsif ( $fs =~ m|^/\w+| ) { # matches /var my_find( $fs, 1 ); } else { # everything else which we ignore # /.ssh # tmp # working/data # /-etc } sub find_me { my @directory = shift; # play nicely with others local $File::Find::prune = shift; <snip> }
If these are not the cases that you want to match I strongly suggest that you think clearly about what you are trying to match. Are relative paths allowed? How about the tmp directory in your current working directory (no / in the path)? Is there a need to restrict directory names to beginning with word characters?
Note that I pass parameters to find_me() rather rely on global variables, find_me() can now be used from elsewhere in the program. Also I localize $File::Find::prune so that changes to File::Find within find_me() don't leak out into the rest of your program. If you don't do that you will have to remember to explicit reset $File::Find::prune before you use any Find::File function elsewhere (or spend hours debugging;).
In reply to Re^3: file::find question
by hipowls
in thread file::find question
by mikejones
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |