File::EmptyDirs - find all empty directories in a path and remove recursively
use File::EmptyDirs 'remove_empty_dirs'; my @abs_dirs_removed = remove_empty_dirs('/home/myself'); my $count_removed = remove_empty_dirs('/home/otherself');
Ever end up with some miscellaneous empty directories in a messy filesystem and you just want to clean up all empty dirs?
For example.. If you have..
And the only thing in this is 'nada', and 'nada' does not contain anything, you'd like to remove both of those. This is what to use. Remove empty directories recursively.
Nothing exported by default.
The operation is self exclusive, that is, if you pass dir /home/myself, it will not delete /home/myself if it is an empty dir.
Argument is an abs path to a directory. Will remove all empty directories within that filesystem hierarchy, recursively.
Returns number of dirs removed in scalar context. In list context, returns abs paths to dirs removed.
Returns undef on failure.
Leo Charre leocharre at cpan dot org
Copyright (c) 2010 Leo Charre. All rights reserved.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the "GNU General Public License" for more details.