I did some more testing to try to figure this out because your reported rare symptoms are weird.

Much to my surprise, the preprocess routine in File::Find does affect the subsequent directory traversal in File::Find.
From the documentation, I didn't think that it would do that, but it apparently does.

The nodirs() sub will leave the initial starting results directory in the results to be used by get_files();

There is no need to use File::Find here because you are only looking at files in the base directory and not navigating to subdirectories.
I would consider just using opendir (my $handle, "dirname") or die "$!" and use readdir(). I am unable to simulate a situation to reproduce your symptoms on my current computer. An unlocked data structure would explain this.

From your code, it appears that this is a multi-process application. Right now, I am thinking that perhaps there is some rare situation where $BASEDIR/$dir doesn't exist.

#!/usr/bin/perl use strict; use warnings; use File::Find; find( { wanted => \&get_files, preprocess => \&nodirs }, "C:/test" ); sub nodirs { grep !-d, @_; } sub get_files { #return unless ( -f $_ ); #testing without this statement # prints: # C:/test <- this is a directory nevertheless! # C:/test/SomeBogusFile.txt return unless ( -f $_ ); #testing with this statement # prints: # C:/test/SomeBogusFile.txt print "$File::Find::name \n"; } __END__ Test Directory structure C:/test SomeBogusFile.txt /subdirtest docinbsubdir.txt

In reply to Re^10: Help with $File:Find by Marshall
in thread Help with $File:Find by roperl

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.