For some reason Perl keeps caching the directory entries I'm trying to read using readdir:
opendir(SNIPPETS, $dir_snippets); # or die...
while ( my $snippet = readdir(SNIPPETS) )
{ print ">>>".$snippet."\n"; }
closedir(SNIPPETS);
Since my directory contains two files, test.pl and test.man, I'm expecting the following output:
.
..
test.pl
test.man
Unfortunately Perl returns a lot of files that have since vanished, for example because I tried to rename them. After I move test.pl to test.yeah Perl will return the following list:
.
..
test.pl
test.yeah
test.man
What's the reason for this strange behaviour? The documentation for opendir, readdir and closedir doesn't mention some sort of caching mechanism. "ls -l" clearly lists only two files.