Problems? Is your data what you think it is? | |
PerlMonks |
Re: Quickly checking if a directory is emptyby alexm (Chaplain) |
on Aug 18, 2009 at 20:55 UTC ( [id://789592]=note: print w/replies, xml ) | Need Help?? |
Using File::Slurp::read_dir() as in:
Update: using File::Slurp or Path::Class will have bad performance on a directory with a large number of entries. However, File::Find::Rule::DirectoryEmpty is addressing the problem the right way, as mentioned by Fletch, by looking for any other entry aside from "." and ".." (which means 3 readdir calls at most whatever the number of entries).
In Section
Seekers of Perl Wisdom
|
|