Hello,
Im trying to iterate LARGE file systems (millions and millions) of objects using opendir() and readdir(), and store the listing of files into a file.
What i am finding is that my script is returning a different number of files every time i run it.
For example,
If i have a directory with 500,000 objects, and i run the script on this directory 3 times, i might get 498,976 then 497,098 or 499,543. I never get the same number of files twice.
I know for a fact that the directory contents are not changing.
my @mntDirs = glob("/mnt/*/clips");
foreach $mntDir (@mntDirs){
my @shallowDirs = glob("$mntDir/*");
foreach $shallowDir (@shallowDirs) {
my @deepDirs = glob ("$shallowDir/*");
foreach $deepDir (@deepDirs) {
opendir (CUR, "$deepDir") or die;
#skip . and ..
readdir(CUR);
readdir(CUR);
while($ent = readdir(CUR)){
print "$ent\n";
}
close CUR;
}
}
}
This is running on a SLES 9 kernel, no NFS or anything.
EDIT: to those who replied, i screwed up my original post, so i had to re-write it.