in reply to Find Empty directories and removing it

Just remove them. If they're not empty, rmdir will fail. In this case, you don't care that it fails, ignore the error, and keep going.

use File::Find; finddepth(sub { rmdir $_ if -d }, $some_path);

Update: added 'depth' as per merlyn's correction.

Replies are listed 'Best First'.
Re^2: Find Empty directories and removing it
by merlyn (Sage) on Jan 04, 2006 at 05:33 UTC
    You have to use finddepth, not find, because you need to act on the current directory last. Consider a directory that is empty except for containing two other empty directories.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.