Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: filesystems & Perlby davido (Cardinal) |
on Aug 12, 2016 at 20:22 UTC ( [id://1169668]=note: print w/replies, xml ) | Need Help?? |
"Eternity is a mere moment, just long enough for a joke." -- Hermann Hesse It's best to look at the list of files in a directory as an approximation of reality. Unless you have a lock on a file, and everyone else is respecting the advisory lock, that file can come and go, or be altered at any time, even while you have it opened. From the moment you read the next entry via readdir to the moment you open the file, to the moment you obtain a lock, those brief moments become an eternity of computing-time during which a bad joke can be played on you. The only certainty you have is after you've obtained a lock, and even then only if other processes are respecting the lock. If the directory can possibly change, you'll need to be tolerant of that possibility. As for opendir and readdir in particular, I would not make critical assumptions about when they will be made aware of changes to the underlying directory's contents. Dave
In Section
Seekers of Perl Wisdom
|
|