in reply to Timed STDIN input via threads on Win32

See the advice in the second reply in this question.
  • Comment on Re: Timed STDIN input via threads on Win32

Replies are listed 'Best First'.
Re^2: Timed STDIN input via threads on Win32
by markperlb0y (Initiate) on Nov 19, 2013 at 02:55 UTC

    That was exactly what I did to solve the thread-safe problem. Inside the read_excel I have that require Win32::OLE line. My problem is that when the timeout expires and I am calling the read_excel sub by creating a thread, then STDIN seems to hang and I have to press enter. If I will call the sub directly, the script continues, however, the problem now becomes the thread-Win32::OLE incompatibility, making the program crash.

      Perhaps you could try Term::Readkey instead? It has built-in support for timeouts. It reportedly works in Win32, and would let you trigger off of a single keystroke, versus the user having to press enter.

        Tried that as well. Unfortunately, it only accepts one character input via ReadKey($timeout). ReadLine does not support > 0 (or non-blocking). The input I'm trying to get from the user can be one or more. I numbered the selection and the user can input as much numbers as there are in the selection and proceed based on his/her selection. I badly need to make this timed STDIN work because the script will be used manually as well as run as a cron/scheduled task..