Subject: | die in IO::Dir->next |
Hello again. If $dir doesn't exist then $dir->next dies with an error message, which is reasonable. (It can't return undef, cos that would be hard to distinguish from the undef that results from all the directory entries having been returned.)
But it'd be good if this behaviour was documented, so people don't have to read the source to find out what happens in such a situation.
Also, using croak rather than die would be better, so that if a user sees the error message it doesn't look to be a bug in your module! I've just changed from using $dir->next and trapping failures with eval and displaying them to the user, because I feared that warnings with Path/Class/Dir.pm in them would only result in people who see the warnings thinking "buggy Cpan modules again" (and unfairly propagating a bad repuation of Cpan) rather than actually fixing the problem that we're missing a directory that's supposed to be there.
I'm now using $dir->open instead, to test for failure before iterating. (The only problem with that is finding a different variable name to use for the directory handle, since I'm already using $dir for the directory object ...)
Smylers