http://www.perlmonks.org?node_id=2311

FiReWaLL has asked for the wisdom of the Perl Monks concerning the following question: (directories)

$directory = '/thedir/thatiwantto/count'; print "\n\n"; print CountSize($directory); print "\n\n"; sub CountSize { my ($directory) = $_[0]; my ($ask, $filesize, $item, $size, @raiz); @raiz = glob("$directory/*.*") || warn(); foreach $item (@raiz) { $ask = -d $item; if ($ask) { $size += &CountSize($item); } else { $size += -s $item; } } return($size); }
It should return the total size of all the tree. In Windows, it works, but in Linux, it doesn't. It returns only the current directory file sizes. What should I do?

Originally posted as a Categorized Question.