#!/usr/bin/perl
use strict;
use LEOCHARRE::CLI2; 
use Cwd;
use File::EmptyDirs 'remove_empty_dirs';
use vars qw/$VERSION @DIRS/;
$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)/g;


@DIRS =
   grep {
      -d $_ or die("Argument '$_' is not a directory on disk.\n")
   } @ARGV;

@DIRS or ( push @DIRS, cwd() );


debug("dirs: @DIRS");

for my $d (@DIRS) {
   -d $d or die("$d not a dir");
   my @removed = remove_empty_dirs($d);

   $opt_d and ( map { warn "# removed: $_\n" } @removed );
   
}





sub usage {q{ermdir [OPTION].. PATH..
Remove empty directories recursively in PATH.

   -d          debug
   -h          help
   -v          version

Try 'man ermdir' for more info.
}}


exit;

__END__

=pod

=head1 NAME

ermdir - Remove empty directories recursively in PATH.

=head1 USAGE

ermdir [OPTION].. PATH..

   -d          debug
   -h          help
   -v          version

Where PATH is one or more directories on disk.

=head1 SEE ALSO

L<File::EmptyDirs> - parent package.

=head1 AUTHOR

Leo Charre leocharre at cpan dot org

=head1 COPYRIGHT

Copyright (c) 2010 Leo Charre. All rights reserved.

=head1 LICENSE

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".

=head1 DISCLAIMER

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.
   
=cut

