Hello htmanning,

> I have a large directory..

just a consideration: to compute stats for large directory is an expensive operation and I'd avoid to call it on the fly on a high traffic server.

More: the path you posted suggests a shared hosting scenario and if so most of the directories dont change in size frequently, if they do at all, so you will waste lot of disk access time to get small or no changes.

Depending on how much critical your needs are I'd follow one these options

A - put a cron scheduled during low traffic hours with a decent nice if needed to populate a static index with an header stating the time of the computation.

B - create a little demon to watch the main path (or the list of all subdirs) perhaps using File::ChangeNotify or similiar modules, and just recompute the size of the subdirectory modified.

PS rereading your post more carefully it seems you need to inspect just a subdirectory not the whole tree :) but, depending on how big and nested these subdirectoris are you may consider my approach anyway. For sure will be more fun to program it :P

If your are maintaining a shared hosting the demon approach has other pros: you can log size changes to spot huge and unwanted uploads, having more control in realtime on quotas. If you populate a static file or a database with your information realtime you will be able to query it or to navigate it in the way you need.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Using Perl for directory listing by Discipulus
in thread Using Perl for directory listing by htmanning

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.