Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Answer: Capturing input from pipe?

by ariels (Curate)
on May 01, 2001 at 14:20 UTC ( #76913=categorized answer: print w/replies, xml ) Need Help??

Q&A > input and output > Capturing input from pipe? - Answer contributed by ariels

Alternatively, if you really do just want to read 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.

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2020-10-31 05:16 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (286 votes). Check out past polls.