Hi ,
Can anyone help me in finding the number of files and their size in Directory.
Can anyone help me in finding the number of files and their size in Directory.
sub dirSize { my($dir) = @_; my($size) = 0; my($fd); opendir($fd, $dir) or die "$!"; for my $item ( readdir($fd) ) { next if ( $item =~ /^\.\.?$/ ); my($path) = "$dir/$item"; $size += ((-d $path) ? dirSize($path) : (-f $path ? (stat($path))[7] : 0)); } closedir($fd); return($size); }
Comment