I haven't used it, but it seems Filesys::DiskUsage could accomplish your goal with one line.
Update: If you want to stick with File::Find, the following closely matches du -s or du -sk on my system:
use strict; use warnings; use File::Find; my $dir = shift; my $k = shift || 0; die "usage: $0 <DIR> [-k]\n" unless -d $dir; my $size; find sub { next if /\.svn$/; $size += -s; }, $dir; $size = int($size/1024)."K" if $k; print "$size\n";
In reply to Re^5: File::Find::prune problems
by hbm
in thread Re^4: File::Find::prune problems
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |