8.100. File::Find
Looks for files that match a particular
expression. Exports two functions.
Works like the Unix find command; traverses the
find (\&wanted, dir1[, dir2 ...])
specified directories, looking for files that match the expressions
or actions you specify in a subroutine called
wanted, which you must define. For example, to
print out the names of all executable files, you could define
wanted this way:
Provides the following variables:sub wanted {
print "$File::Find::name\n" if -x;
}
- $File::Find::dir
Current directory name ($_ has the current
filename in that directory).- $File::Find::name
Contains $File::Find::dir/$_. You are
chdired to $File::Find::dir
when find is called.- $File::Find::prune
If true, find does not descend into any
directories.- $File::Find::dont_use_nlink
Set this variable if you''re using the Andrew File
System (AFS).
Like find, but does a depth-first search.The standard Perl distribution comes with a Perl script,
finddepth (\wanted, dir1[, dir2...])
find2perl, which takes a Unix
find command and turns it into a
wanted subroutine.