Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Checing presence of input on standard input in non-blocking way, sans user interaction

by marinersk (Priest)
on Jul 17, 2013 at 15:35 UTC ( [id://1044846]=note: print w/replies, xml ) Need Help??


in reply to Checing presence of input on standard input in non-blocking way, sans user interaction

If I read you correctly, you are looking for a Perl version of the BASIC $Inkey function.

I think in C it was usually the keyPress() function.

In other words, you want to be able to see if there's a reason to process input without stopping your program to wait for it. AND you want it to work even if the user had redirected input.

There is no pure Perl solution to this that I'm aware of -- over the years, I have checked from time to time.

Not sure why you wish to avoid using Term::Readkey but without that I would expect you to not find a solution.

If you do find one, I'd personally appreciate knowing about it here on Perlmonks.

Good luck in the hunt!

  • Comment on Re: Checing presence of input on standard input in non-blocking way, sans user interaction

Replies are listed 'Best First'.
Re^2: Checing presence of input on standard input in non-blocking way, sans user interaction
by Anonymous Monk on Jul 18, 2013 at 07:35 UTC

    "In other words, you want to be able to see if there's a reason to process input without stopping your program to wait for it. AND you want it to work even if the user had redirected input." -- marinersk

    Indeed. My objective is to collect input from any & all of the ways, as in command | program.pl file < file2.

    "Not sure why you wish to avoid using Term::Readkey but without that I would expect you to not find a solution." -- marinersk

    It is not that I want to avoid use of T::R. I am|was curious if I might have missed something otherwise obvious to others (say on the lines of readline, sysread, select, tell, etc).

      Ah, understood.

      I will be watching this thread for awhile; if there is a procedure (or even a trick) out there for capturing this, I'd be interested in knowing it.

      Not holding my breath, mind you, but definitely interested.

      :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1044846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (1)
As of 2024-04-19 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found