in reply to Re^2: Testing for readdir failure (Perl-bug)
in thread Testing for readdir failure

I can't neither help you on the C-level, Perl source code is very special with all its preprocessor macros.

(UPDATE. striked nonsense, see reply)

In the case of readdir the following should help

$! = undef; @a = readdir(D) or process_errno();

But in the case of readline it doesn't.

The other advices I gave you - like catching $SIG{WARN} - are still valid,

I will post the ticket-link after reporting the perlbug.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^4: Testing for readdir failure (Perl-bug)
by Bob Cook (Acolyte) on May 27, 2013 at 22:20 UTC
    @a = readdir(D) or process_errno();

    So you are assuming, if for example an I/O error occurs while the directory is being read, that the result of readdir will be an empty (or undefined) directory. Is that guaranteed to be true? It seemed to me that it might instead provide as much of the directory as it successfully read.

      Ups sorry I was in a hurry!

      Of course you're right this is nonsense!

      I just copied the open() || die pattern, even with the wrong or operator.

      Forget what I said, your version of testing '$!' in the next line should be fine!

      Cheers Rolf

      ( addicted to the Perl Programming Language)