Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Using stat()

by samtregar (Abbot)
on May 24, 2002 at 04:51 UTC ( [id://168976]=note: print w/replies, xml ) Need Help??


in reply to Using stat() to get the total size of files in a folder

How about:

use File::Find; my $size = 0; find(sub { $size += -s if -f $_ }, "foo");

That will recurse down into subdirectories. If that's not what you want, you could use:

use File::Find; my $size = 0; find(sub { $size += -s if $File::Find::name eq "foo/$_" and -f $_}, "f +oo");

-sam

Replies are listed 'Best First'.
Re: Re: Using stat()
by neilwatson (Priest) on May 24, 2002 at 13:34 UTC

    Sam has it right. File::Find is very fast and efficient. You can see a good example on my website

    Neil Watson
    watson-wilson.ca
      Ok, I've decided to use File::Find. When I call the find() function, I get this error.Insecure $ENV{PATH} while running with -T switch at /usr/lib/perl5/5.6.1/Cwd.pm line 92.So, I decided to add $ENV{PATH} = '/bin:/usr/bin'; to my script. Now, I'm getting this error.Insecure dependency in chdir while running with -T switch at /usr/lib/perl5/5.6.1/File/Find.pm line 467.I noticed in Neil's script, It didn't have the -T switch. Will File::Find just not run in taint mode?

      Thanks.
      Joshua

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-18 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found