If you're wanting to sum the sizes of all files within a directory, this should do it:
my $dir = '/path/to/dir'; my $dir_size = 0; my $file; opendir DIR, $dir or die "Unable to open $dir: $!\n"; $dir_size += -s "$dir/$file" while defined( $file = readdir DIR ); closedir DIR; print $dir_size;
This does not descend into subdirectories, though.
In reply to Re: size of directory
by mikeirw
in thread size of directory
by darshan_atha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |