File::Find
Gathering an array of directories
Starting @ $one_up_path, traverse the directory tree pushing all relative directories (except those we are ignoring) into @dirs.
my @dirs;
use File::Find ;
no warnings 'File::Find'; # suppresses -w 'Variable "@dirs" will not stay shared'
find(\&ffdir, $one_up_path); # $one_up_path is my 'start in' directory
sub ffdir {
if (-d) {
my $dir = $File::Find::name;
$dir =~ s!$ENV{'DOCUMENT_ROOT'}/(.*)!$1!;
if ($dir!~m!^(images|files|cgi-bin)$!){
push (@dirs, $dir);
}
}
}
[ comment | link | top ]
Links
- File::Find
- Man page
[ comment | link | top ]
- Randal L. Schwartz/stonehenge.com
- Recursive directory tasks (sep 97)
[ comment | link | top ]
- File Find Rule
- Perl File::Find::Rule. A simple/easy front-end to File::Find. I'm hesitant to use anything that isn't a core module. This page shows some practical usage examples.
Cache
[ comment | link | top ]