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().
In Section
Seekers of Perl Wisdom