Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Testing <>

by Corion (Pope)
on Oct 03, 2011 at 15:31 UTC ( #929363=note: print w/replies, xml ) Need Help??


in reply to Testing <>

STDIN is always there.

Maybe you want to detect instead of whether your script is supposed to get interactive input or input piped from a file, or another program?

if( -t and !@ARGV) { die "Need a file or stream on standard input"; }; while (<>) { ... };
>perl -w tmp.pl Need a file or stream on standard input at tmp.pl line 2. >perl -w tmp.pl tmp.pl >perl -w tmp.pl <tmp.pl

Replies are listed 'Best First'.
Re^2: Testing <>
by Anonymous Monk on Oct 03, 2011 at 15:49 UTC
    Thanks Corion.

    That's the simple solution I knew had to be there. I didn't know you could use -t in that context. Oh well live and yearn.

    Thanks again

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://929363]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2016-12-09 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (158 votes). Check out past polls.