I highly recommend getting in the habit of making your programs filters. Happily, Perl has a great way to do this:
while (<>) { # do stuff on $_ line by line }
This will either take direct STDIN (run the program, it sits there, you enter lines of text until you hit ctrl-D), or take a list of filenames on the command line and process their contents as STDIN. Because this idiom doesn't use any textual identifier (like ARGV or STDIN), and because it's a difficult concept for a newbie to describe or search for (or even to conceive of), it's often something people don't pick up on early. I'm going to go on a limb and counsel a novitate to "just do it," and adapt your intentions to fit this idiom.

It's not exactly what you described -- the others' @ARGV solutions are for that -- but if you can alter your requirement slightly, writing programs as filters has a lot of benefits. See The Art of Unix Programming for why.


In reply to Re: How do I read data passed to perl script by rlucas
in thread How do I read data passed to perl script by dtharby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.