If you really want to use File::Find...
However, I doubt this is what you want to do. I would suggest:## start in the dir above your client dirs use File::Find; my @del_dirs; find(\&del_dirs, '.'); sub del_dirs { return unless -d $_; return unless $File::Find::name =~ m{^\./.+?/.+}; # at least in pro +ject level return if $File::Find::name =~ m{^\./.+?/.+?/.+}; # but no lower ### check for age or whatnot here, return if you don't want deletio +n ### push @del_dirs, 'rm '.$File::Find::name; }
my @del_dirs; opendir primary, '.' or die $!; foreach my $client (readdir primary) { opendir client, $client or die $!; foreach (readdir client) { ## check date, etc. use 'next' if you want to keep push @del_dirs, 'rm '.$client.'/'.$_; } closedir client; } closedir primary;
In either case, your delete list ends up in @del_dirs;
The glob-based solutions above would work, too, but readdir tends to be faster than glob.
In reply to Re: Get list of first level subdirectories
by radiantmatrix
in thread Get list of first level subdirectories
by gwhite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |