Something like this ...
sub dir_size { my $dir = shift; local *DIR; my $size = 0; my $file; opendir(DIR, $dir) or die "Failed to open $dir: $!\n"; while ($file = readdir(DIR)) { # Skip . and .. if ($file !~ /^\.\.?$/) { if (-d "$dir/$file") { $size += dir_size("$dir/$file"); } else { $size += -s "$dir/$file"; } } } closedir(DIR); return $size; } my $size = dir_size("/foo/bar");
In reply to Re: Getting the size of files and stuff
by steves
in thread Getting the size of files and stuff
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |