The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
use strict;
use LEOCHARRE::CLI2 ':all', 's';
use LEOCHARRE::Dir 'lsda';
use Cwd;
our $VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)/g;



my %d;

(scalar @ARGV) or (push @ARGV, cwd());

for my $arg (@ARGV){

   -d $arg or die("Is not dir: '$arg'\n");


   for my $abs ( lsda($arg) ){
      debug("getting info for $abs");
      my $du = `du -hs '$abs'`;
      $du=~s/\W.+$//s;   
      $d{$abs} = $du;
   }
}

my @d =
   $opt_s  
      ? ( sort { $d{$b} <=> $d{$a} } keys %d ) 
      : ( sort keys %d );

(printf "%10s %s\n", $d{$_}, $_ ) for @d;

exit;

sub usage {q{lsdu [OPTION].. PATH..
List disk usage of subdirectories of PATH.
   
   -s          sort by size
   -h          help
   -v          version
   -d          debug

Try 'man lsdu' for more info.
lsutils - parent package
}}





__END__

=pod

=head1 NAME

lsdu - List disk usage of subdirectories of PATH.

=head1 USAGE

lsdu [OPTION].. PATH..
List disk usage of subdirectories of PATH.
   
   -s          sort by size
   -h          help
   -v          version
   -d          debug

=head1 EXAMPLE USAGE

   lsdu
   lsdu ./path2dir

=head1 SEE ALSO

lsutils - parent package

=head1 AUTHOR

Leo Charre leocharre at cpan dot org 

=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