Perl FAQ 5.17: Why can't my perl program read from STDIN after I gave it ^D (EOF) ?

Perl FAQ 5.17

Why can't my perl program read from STDIN after I gave it ^D (EOF) ?

Because some stdio's set error and eof flags that need clearing.

Try keeping around the seekpointer and go there, like this:

     $where = tell(LOG);
     seek(LOG, $where, 0);
    

If that doesn't work, try seeking to a different part of the file and then back. If that doesn't work, try seeking to a different part of the file, reading something, and then seeking back. If that doesn't work, give up on your stdio package and use sysread. You can't call stdio's clearerr() from Perl, so if you get EINTR from a signal handler, you're out of luck. Best to just use sysread() from the start for the tty.


Other resources at this site: