Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 Need a file or stream on standard input at line 2. >perl -w >perl -w <

Comment on Re: Testing <>
Select or Download Code
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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-12-28 10:40 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (180 votes), past polls