in reply to Re^2: Read files not subdirectories
in thread Read files not subdirectories
On many systems, doing something to a file ... even, just opening it ... can interfere with a directory-scan, causing it to end prematurely, to list the same file more than once, and so on. (And this would be true no matter what high-level language e.g. Perl was being used to do it.)
Therefore, I suggest that you first retrieve the entire list of files into an in-memory list ... which you can very easily do in Perl just by using the list context. Then, iterate through the in-memory list that you have just retrieved, checking to see if they are or aren’t directories and so-on. Start and finish the task of retrieving the list, for any given directory that you are now “in” ... then process the list.
Of course, “file finding” is such a common requirement that there are many CPAN modules like File::Find. If you need to “take a walk through a directory tree,” there are plenty of tour-guides . . .