http://www.perlmonks.org?node_id=929359

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Simple problem for you good folks.

I want a script that reads both from stdin and from a any file parameter. In other words a script that can be used as any other unix command line tool.

The problem is that if there's no stdin and no command line args then the script just waits for input.

I want to test to see if there is any input from a pipe or file and if not close with a usage message. How can I test, <>?

Thanks

use strict; use warnings; while (<>) { print; }