in reply to Open directory command in perl
I would expect the outcomes to be unpredictable. The directory-scan is, by definition, passing through a highly volatile data structure without the benefit of locks. The data structure being traversed, in most file systems, is not simply “a list,” but a tree of some kind. If the directory is updated while a particular scan is going on, the results of that scan might be quite unpredictable ... with omitted entries, possible duplicates, and so on.
A program which makes any assumptions at all about the outcome of this scenario will, eventually, produce incorrect results ... probably without realizing that it has done so.