joshua has asked for the wisdom of the Perl Monks concerning the following question:
I'm using stat() to get the total size of the files in a given folder. I've been using something like this.
This seems like a lot of code to do a simple task. But if I use my $size = (stat("foo"))[7]; it returns 4096, but the total size of the files in that directory are 30981 bytes.my $size = 0; opendir (FOO, "foo") or error_stuff(); foreach (readdir(FOO)) { $size += (stat("foo/$_"))[7] unless /^\.\.?$/; } closedir (FOO);
Is there an easier way to do this, or it this my best bet?
Thanks
Joshua
Edit kudra, 2002-05-26 Changed title
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using stat()
by vladb (Vicar) on May 24, 2002 at 04:55 UTC | |
Re: Using stat()
by samtregar (Abbot) on May 24, 2002 at 04:51 UTC | |
by neilwatson (Priest) on May 24, 2002 at 13:34 UTC | |
by joshua (Pilgrim) on May 29, 2002 at 17:24 UTC | |
Re: Using stat()
by sfink (Deacon) on May 24, 2002 at 19:08 UTC | |
by Anonymous Monk on Nov 25, 2011 at 09:34 UTC | |
by Anonymous Monk on Nov 25, 2011 at 10:04 UTC | |
by pankaj_it09 (Scribe) on Nov 25, 2011 at 10:11 UTC | |
by Anonymous Monk on Nov 25, 2011 at 10:13 UTC | |
| |
Re: Using stat()
by joshua (Pilgrim) on May 25, 2002 at 04:57 UTC |
Back to
Seekers of Perl Wisdom