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.

In reply to readdir inconsistent! by LostShootingStar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.