http://qs321.pair.com?node_id=11147174


in reply to Using Perl for directory listing

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.