When the readdir fails to deliver the entire contents of the directory, there is NO warning, nor any other message, issued by Perl. Thus, I don't believe that trapping warnings, nor the warnings pragma, will help.
It may be right, but if you don't try, you'll never know. Especially, if you don't turn on warnings with the warnings pragma, you're not gonna get those warnings. In my tests, when I tried to readdir on a close dir, I did not get any message unless I explicitly added the 'or die "$!"' clause to my readdir instruction.
Consider this:
$ perl -e '@c=readdir DIR ; print "@c\n";'No warning, nothing. Compare to this;
$ perl -w -e '@c=readdir DIR ; print "@c\n";' Name "main::DIR" used only once: possible typo at -e line 1. readdir() attempted on invalid dirhandle DIR at -e line 1.
Turning on the warnings with the -w command line option gave me two warnings that might explain where my problem is. Or consider this:
$ perl -e '@c=readdir DIR or print "$!"; print "@c\n";' Bad file descriptor
In reply to Re^3: Testing for readdir failure
by Laurent_R
in thread Testing for readdir failure
by Bob Cook
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |