examples/du.pl

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4.  
  5. use Filesys::DiskUsage qw(du);
  6.  
  7. if (not @ARGV) {
  8. die "Usage: $0 DIRs\n";
  9. }
  10.  
  11. my %sizes = du({'make-hash' => 1}, @ARGV);
  12. foreach my $entry (sort { $sizes{$a} <=> $sizes{$b} } keys %sizes) {
  13. print "$entry => $sizes{$entry}\n";
  14. }
  15.  

Comments

Very helpful and I love you did a VDO too! Smooth and elegant presentation. I'm an APL-trained programmer always seeking brevity. My lines might be (untested!):

use feature "say"; use Filesys::DiskUsage qw/du/'

die "Usage: $0 DIRs\n" unless @ARGV; my %sizes = du({'make-hash' => 1}, @ARGV); say "$_ : $sizes{$_}" for sort { $sizes{$a} <=> $sizes{$b} } keys %sizes;

As an aside- seems difficult to install Filesys::DiskUsage . CPAN install fails.