in reply to How to handle both a STDIN pipe and file from command line?

perldoc -f -x

-p File is a named pipe (FIFO), or Filehandle is a pipe.

if( -p STDIN ){ @stuff = <STDIN>; close STDIN; } while(<>){ ...

See Re^2: Write to existing file with character insert and Iterator::Diamond for a safer way