Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
We don't bite newbies here... much
 
PerlMonks  

Re: detect input available from command line

by BioLion (Curate)
on Mar 11, 2011 at 09:58 UTC ( #892632=note: print w/ replies, xml ) Need Help??


in reply to detect input available from command line

I think OP needs to clarify whether he wants to prompt for input e.g prompt function or take arguments from the command line e.g. @ARGV or getopt::long...

Hope this helps!

Just a something something...


Comment on Re: detect input available from command line
Re^2: detect input available from command line
by mifflin (Curate) on Mar 11, 2011 at 16:49 UTC
    I want to know when
    while (<>) { }
    has something available to read. I'd like to not execute this code when there isn't something available because it will block.

    This idiom will read when @ARGV is populated or when there is some data available to read on STDIN.

    I can handle detecting whether @ARGV has data. What I'm not sure on is how to detect whether STDIN has something available to read. Still testing but I'm not convinced, yet, that -t, as suggested by others, will work here.

      One thing you can do is start a second thread. Let that thread do the blocking read, and pass results to the main thread as they become available.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-04-24 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (563 votes), past polls