I'm using ... Activestate Perl
So you are very likely using Windows. There are ActiveState Perls for some Unix systems, but as most Unix systems have some Perl out of the box, ActiveState's Perl is rarely found on Unix systems.
I'll ... add up all the file sizes in the directories, I assume this will be slower than a stat on a dir?
Did you actually read my first answer? Let me repeat the two important points:
- The size value returned by stat() for a directory is IN NO WAY RELATED to the size of the files the directory contains.
- The size value returned by stat() for a directory may legally be COMPLETE NONSENSE (according to POSIX).
What is your intention?
- If you want to know the total number of bytes that the files in a directory use, THERE IS NO OTHER WAY than summing up their individual sizes returned by stat(). The size value returned by stat returns nonsense.
- If you want to know how much disk space is "wasted" by the directory itself, not by the files it contains, the size value returned by stat() for the directory itself MAY BE useful - IF your operating system cooperates (Windows DOES NOT) AND IF the actual filesysem has this information (remember that sysfs and procfs on Linux usually return 0).
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)