leocharre has asked for the wisdom of the Perl Monks concerning the following question:
Is it because it's just testing for file (as in file, not dir) size?use File::Find::Rule; use Smart::Comments '###'; my $path = '/home/myself'; mkdir "$path/nothing"; my $finder= File::Find::Rule->new; $finder->directory(); $finder->empty(); my @found = $finder->in($path); ### @found
update This seems to work :
use IO::Dir; use File::Find::Rule; sub _is_empty_dir { my ($shortname, $path, $fullname) = @_; my $dh = IO::Dir->new($fullname) or return; my $count = scalar(grep{!/^\.\.?$/} $dh->read()); $dh->close(); return($count==0); } sub emptydirfinder { my ($self,$abs) = shift; $abs or die(); my $finder= File::Find::Rule->new; $finder->directory(); $finder->exec( \&_is_empty_dir); my @found = $finder->in($abs); return \@found; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to get File::Find::Rule to match empty directories
by runrig (Abbot) on May 25, 2007 at 06:02 UTC | |
|
Re: how to get File::Find::Rule to match empty directories
by ikegami (Patriarch) on May 25, 2007 at 06:22 UTC | |
by chb (Deacon) on May 29, 2007 at 07:39 UTC |