in reply to Re^9: Help with $File:Find
in thread Help with $File:Find

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