Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: detect input available from command line

by Eliya (Vicar)
on Mar 10, 2011 at 22:02 UTC ( #892545=note: print w/replies, xml ) Need Help??


in reply to Re^2: detect input available from command line
in thread detect input available from command line

You could test

if (@ARGV or !-t STDIN and !eof()) { while (<>) { ...

(but any non-input file arguments would need to be removed from @ARGV first, of course)

This should work with input file arguments on the command line, heredoc input (<<), input redirect (<), and piping into the program (|).

Update: actually, I think you don't even need the eof().

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2023-03-27 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (65 votes). Check out past polls.

    Notices?