in reply to Re^4: Testing for a directory handle
in thread Testing for a directory handle

I will send an email to perlbug@perl.org

The error message first appears in perl-5.8.9.
In 5.8.8 (and probably earlier) -f and -d calls on a directory inevitably returned false, without warning or error.
So I guess that making them fatal and providing a relevant error message was just their way of dealing with what is apparently an issue specific to Windows.
(No such problem exists on Linux.)

So ... I'm not sure that the porters will be all that keen to do anything about this shortcoming - in which case the bug is in the documentation. We'll just have to wait and see.
If it's not something that's going to be fixed then it's something that, along with its workaround, should be prominently documented in both the perlport and the -X docs.

The Windows workaround to -d HANDLE that comes to my mind is that you do:
eval{-d $handle}; if($@ =~ /dirfd function is unimplemented/) { # then you know $handle is a dirhandle } elsif($@) { die $@; # a different problem } else { # it's safe to call -X on $handle }
But others might know of better workarounds.

Cheers,
Rob

Replies are listed 'Best First'.
Re^6: Testing for a directory handle
by ns550 (Novice) on Jan 29, 2018 at 23:36 UTC

    Yes, I agree

    It should be documented and/or fixed if possible. It could just be added to the list of port issues on https://perldoc.perl.org/perlport.html#-X. But it would be nice if it worked properly as it is a core function.

    I will keep these work-arounds in mind when I am coding. Thanks, Matt