Hello,
I found the following code in Perl Monks to search for top 10 largest files in a filesystem. But it searches in all sub directories of different filesystem. Example., I have /var and /var/log filesystems, my requirement is to search top 10 files under /var but the code searches through /var/log too. is there a way to restrict the search with teh current filesystem alone with this script using File:find and warning subroutine?
use File::Find;
File::Find::find(
{
wanted => sub {
return unless -f;
my $s = -s _;
return if $min < $s && @z > 10;
push @z, [ $File::Find::name, $s ];
@z = sort { $b->[1] <=> $a->[1] } @z;
pop @z if @z > 10;
$min = $z[-1]->[1];
}
},
shift || '.'
);
for (@z) {
print $_->[0], " ", $_->[1], "\n";
}