in reply to Re^4: File::Find::prune problems
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: File::Find::prune problems
by Anonymous Monk on Jan 20, 2009 at 21:33 UTC |