--- name: File::Find runtime: pp source: src/native/File/Find/pp.rs --- ```{index} single: File::Find; Perl module (pp runtime) ``` # File::Find Native implementation of File::Find Provides recursive directory traversal: find() and finddepth(). The find() function takes a hash ref of options (or a code ref) and a list of directories to search. It recursively visits each file/directory and calls the wanted() callback. # Synopsis use File::Find; find(sub { print "$File::Find::name\n" }, '/home'); find({ wanted => sub { print "$_\n" if -f }, no_chdir => 1, }, @directories); finddepth(sub { rmdir $_ if -d }, '/tmp/tree'); # Functions ## find Traverse a directory tree in top-down order, calling the wanted() callback for each file and directory. Sets `$File::Find::name`, `$File::Find::dir`, and `$_` for each visited entry. ```perl use File::Find; find(sub { print "$File::Find::name\n" }, '/tmp'); find({ wanted => \&process, no_chdir => 1 }, @dirs); ``` ## finddepth Traverse a directory tree in bottom-up (depth-first) order. Equivalent to calling find() with the `bydepth => 1` option: directories are processed after their contents. ```perl use File::Find; finddepth(sub { print "$File::Find::name\n" }, '/tmp'); ```