-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give more informative error when using a filehandle as a directory handle #22394
Comments
Given that the two-argument form to
... So that leaves only the possibility of providing a more specific error warning for
or, without warnings, but checking for success of
I'm not persuaded that the |
Well we have at least one example of a user for whom it wasn't sufficient. I'm not sure if the full glob or just the dirhandle is available at this point, but if it's possible I think it would be helpful to have a "did you use open() instead of opendir()" style message when the glob has an open filehandle. (If we have only the dirhandle, perhaps there's a way to find back the (likely) glob from it, though I appreciate that's likely to be both harder and less canonical.) |
On the face of it, looks like the glob should be available and it should be possible to test for |
Module:
Description
If you mistakenly call
open
(rather thanopendir
) on a directory, and then try to read from what you thought was a directory handle, you will get an unclear error. This could be improved.(This was inspired by this Perlmonks discussion.)
Steps to Reproduce
output:
readdir() attempted on invalid dirhandle $dh at test.pl line 7.
Expected behavior
A not-unreasonable expectation would be an error or warning when trying to call
open
on a directory, but it seems like there's nothing intrinsically invalid about doing this. However, when callingreaddir
on a filehandle, perhaps a better error could be reported.Perl configuration
The text was updated successfully, but these errors were encountered: