use File::Find;
####
use File::Find;
my $dir = # whatever you want the starting directory to be
find(\&do_something_with_file, $dir);
sub do_something_with_file
{
#.....
}
##
##
use File::Find;
find(\&print_name_if_dir, ".");
sub print_name_if_dir
{
print if -d;
}
##
##
print if -d;
##
##
print $_ if -d $_;
##
##
sub print_name_if_dir
{
my $file = $_;
print $file if -d $file;
}
##
##
use File::Find;
my $dir = # whatever you want the starting directory to be
find(sub {print if -d}, $dir);
##
##
use File::Find;
find(sub {print $File::Find::name if -d}, ".");
##
##
use File::Find;
find({wanted => sub {print $File::Find::name if -d}
no_chdir => 1}, ".");
##
##
#!/usr/local/bin/perl -w
($#ARGV == 0) or die "Usage: $0 [directory]\n";
use File::Find;
find(sub {$size{$File::Find::name} = -s if -f;}, @ARGV);
@sorted = sort {$size{$b} <=> $size{$a}} keys %size;
splice @sorted, 20 if @sorted > 20;
foreach (@sorted)
{
printf "%10d %s\n", $size{$_}, $_;
}