![]() |
|
|
|
#1 |
|
Help!
I'm recursing through 10,000 directories where some have as few as 5 files and others have 100's. I'm then performing a few things based on the modify date of the file. Needless to say, this script is going to run a long time regardless of what I do. But if I remove the stat, the script runs 500% faster (duh). That being said, I've set out to find something faster than stat if at all possible (since stat gets much more info than I need). I've noted that doing a file check (-f) slows down execution significantly so I've removed it in favor of regular expressions, but I can't find another way to get the modify date of each file other than stat and -M. Anyone have any other ideas? I'm running this in Win32, so I'm sure that's part of the cause, but perhaps there's a stat-like command that ONLY grabs modify date, or perhaps there's something in a Win32 module that I haven't found. Here's a snippet of code in case it helps. # open the current directory opendir D, "$checkpath"; # loop through files in directory while (defined($file = readdir D)) { chomp($file); # if there's a . in the file, it must be real (weak but works for now) if ($file=~ /\./) { # get the time, in seconds, of the file since Jan 1 1970 $filetime = int((stat($file))[9]); <--- SLOW! # do something with it... } } Thanks in advance! -Ken Ken Tucker |
|
|
|
|
#2 |
|
Posts: n/a
|
Ken Tucker <> wrote:
> Forget stat(). I just used regular expressions to parse through > a DOS directory listing ... it went from 256 seconds to 16 seconds That will be specific to Windows. > So - word to the wise - [ insert joke here ] -- Steve |
|