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 (Hermit) 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.