http://qs321.pair.com?node_id=76913


in reply to Capturing input from pipe?

If you want to read only the standard input, you can read the predefined filehandle STDIN. For instance, to add line numbers to all lines coming from your pipe, you could do this:
#!/usr/local/bin/perl -w use strict; while (<STDIN>) { print "$. $_" }

But almost any program is more useful if it can read either STDIN or filenames supplied on the command line. So reading <> almost always makes more sense.