in reply to Need to delete empty directories.

use File::Find; my @dirs; my @search_dirs = qw(. ..); find(\&wanted, @search_dirs); sub wanted { -d && push @dirs, $File::Find::name } # do sm.th. with directories in @dirs


Replies are listed 'Best First'.
Re^2: Need to delete empty directories.
by sashac88 (Beadle) on Mar 09, 2005 at 13:02 UTC
    I can delete empty directory with rmdir.
    Since if I delete some directory -it's parent directory can
    become empty-I need to delete it too.
    Thus what I need is loop of deletions of empty directories.
    However I want to limit this loop to the maximum
    deepness.
    Thanks in advance.
      use strict; use File::Find; my @topdirs = @ARGV; my @rmdirs; find( sub { -d and push @rmdirs, $File::Find::name }, @topdirs ); rmdir for reverse @rmdirs;