Besides the problems mentioned by the others, the line
next unless -d $_;
is suspect as well. $_ refers to the filename in the directory. This means that $_ isn't absolute, and hence the -d is done relative to the current directory. Unless the current directory is the same as where File::Find happens to be searching, it's not going to work.

Also be aware your approach is flawed. A stat() of a directory just gives you the size of the directory node in the file system. This has no relation to the total size of the files found in the directory. It's only related to the number of files (and perhaps the length of the filenames), or rather the maximum number of files the directory has had over its lifetime. (On some filesystems, directories may shrink in size, but on many filesystems, they do not).

You should be adding file (and directory) sizes. But you have to be careful. A 1 Mb file with 3 links should not be counted three times - the data is there only once.

Some OSses have commands that will report disk usage by UID on a filesystem. You might want to look into them.

Abigail


In reply to Re: help with FS usage script using a data struct by Abigail-II
in thread help with FS usage script using a data struct by neptuna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.