Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Using stdin only if there is input on it, but skipping it if there is no data

by Fletch (Bishop)
on Nov 18, 2020 at 07:48 UTC ( [id://11123772]=note: print w/replies, xml ) Need Help??


in reply to Using stdin only if there is input on it, but skipping it if there is no data

First thing that comes to mind is if @ARGV were empty (you're given no filenames) then check if -t STDIN is true (meaning it's a tty device not a pipe).

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Using stdin only if there is input on it, but skipping it if there is no data
by mldvx4 (Friar) on Nov 18, 2020 at 08:53 UTC

    Thanks. That seems to allow me to use redirects and does not interfere if there is not.

    . . . } elsif ($#filenames < 0 && ! -t STDIN) { unshift(@filenames, '/dev/stdin') } . . .

    It is done at the end of all the checking of sources, right before the data gets read.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found