> -----Original Message-----
> From: Nick [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, August 28, 2005 1:26 PM
> To: Perl Beginners
> Subject: Directory Size
> 
> Hi All,
> 
> Is there a way to get an entire directory and all 
> sub-files/folders size in Perl? Basicly, I need the Perl 
> version of "du -s".
> 
> I've currently done it with stat but this only gives a 
> directory size not taking into consideration everything inside it.
> 
> Nick
> 

Try this:


use File::Find;

my $dir = $ARGV[0];
my $size;

find( sub { -f and ( $size += -s _ ) }, $dir );







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to