Are you running any other programs from your script, using
system, for example? It could be that a child process is using stdin, rather than your perl.
Another weird affect might be had with opening a file whose filename contains '|'.
Furthermore, this happens intermittently, and it can happen anywhere in the program.
If that is true, then is something else using the console window? How was the perl program launched? In Windows, by default, a child process uses the parent's console. Maybe the parent is getting in the way. Another possibility is that stdout is screwed-up with an output buffer getting full and blocking, I have seen some weird effects from "|more" on Windows.