Dan Cox <[EMAIL PROTECTED]> wrote:
> How do you get a directory's size? 

  -s $dir;

But if you want disk usage, count blocks instead of bytes
and use File::Find to recurse.

    use File::Find;

    my $BLOCK_SIZE = 512;
    my $total = 0;

    sub wanted {
        $total += (lstat)[12]*$BLOCK_SIZE;
        $File::Find::prune = -l _;
    }

    find \&wanted, $ARGV[0];
    print "$total\n";

Doesn't quite tally with du(1), though...

(But it's faster ;)

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to