in reply to Re: finding top 10 largest files
in thread finding top 10 largest files

My idea is very similar to both borisz's and Abigail's. borisz's solution has some "issues":
  1. the return line should be
    return if $s < $min && @z == 10;
  2. the numeric sort is inefficient because it entails several perl ops. My solution uses GRT for maximum efficiency.
File::Find::find( sub { return unless -f; @z = sort @z, sprintf( "%32d:", -s ) . $File::Find::name; shift @z if @z > 10; }, $dir ); print "$_\n" for @z;

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.