#!/usr/bin/perl use File::Find; my $dir = $ARGV[0] || '.'; find( sub { -f and $h{$File::Find::name} = -s }, $dir ); print "$h{$_}\t$_\n" for sort { $h{$b}<=>$h{$a} } keys %h; #### #!/usr/bin/perl use File::Find; die "Usage $0 \n" if $ARGV[0] =~ m/-h/; my $dir = $ARGV[0] || '.'; my $num = $ARGV[1] || 20; # how many files to print my %h; find( sub { -f and $h{$File::Find::name} = -s }, $dir ); for ( sort { $h{$b} <=> $h{$a} } keys %h ) { printf "%s\t%s\n", add_commas($h{$_}), $_; last if --$num == 0; } sub add_commas { my ( $number ) = @_; return undef unless $number; ( $number, my $dec ) = $number =~ m!([+-]?\d+)\.?(\d*)!; return undef unless $number; $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1,/g if length($number) > 3; return $dec ? "$number.$dec" : $number; }