You can get the same guantee by simply turning off the check-nlinks "optimization":

$File::Fin­d::dont_us­e_nlink= 1;

as I mention from-time-to-time such as in Re: File::Find in a thread safe fashion (speed).

It is unfortunate that this fact isn't documented. It is also sad that this "fastest for the most common cases" method is not easier to use and that $dont_use_nlink has nearly been eliminated from the documentation -- the maintainers continue their delusion that they have succeeded in this latest repeat of trying yet again to make this "optimization" safe and refuse to realize that this "optimization" actually makes typical uses of File::Find slower (and more complex) than they need to be (it only speeds up very limited cases where you are selecting files solely based on their names, except when it just doesn't work right).

Update: Doing some quick testing I find that File::Find may have broken this guarantee (as I said in the linked node, the code is now too complex for me to easily see that the guarantee still applies like it did ages ago when I first discovered this trick) and File::Find may no longer give faster results when you use it this way (like it did ages ago). My first suspicion given both of these results (which may be a result of flawed testing on my part, as it was just a quick hack of a test) is that File::Find is doing more than it needs to, but I'm not going to spend more time trying to figure out what's really going on with this module that I never use. Indeed, just rolling my own replacement for File::Find cuts my run-time in half.

My quick hack of a test also validates Tanktalus' point, though testing eons ago did show a speed-up for me. Tanktalus++

- tye        


In reply to Re: Can the special underline filehandle (stat cache) be cleared? (nlinks) by tye
in thread Can the special underline filehandle (stat cache) be cleared? by ammon

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.