Your question has mostly been answered, but I think a short abstract on all the available options is in order.
  1. Commandline parameters are available to the script via the @ARGV array. You can also modify this array at runtime to suit your needs, if desired.
  2. The Getopt:: modules are great help if you want to pass more parameters on the commandline than just filenames, @ARGV mangling can be very tiresome. These modules do the job for you with a lot of flexibly and robustness.
  3. If you use the plain diamond operator <>, Perl will read data from STDIN if no command line parameters have been passed, or use the scalars in @ARGV as the names of the files to read. It will read all of the files given there without you having to explicitly open/close any of them. Note that you can manually munge @ARGV and Perl will willing pick up the modified list of filenames.
  4. Unless you need to output to several files, I would suggest you print to STDOUT. To capture the output to a file, the shell offers redirection, so there is no extra work involved. But if you call that script from another one, its output will be much easier to work with if it prints to STDOUT instead of a file.
Hope this helps. (Although I'm sure it's not entirely complete. :))

Makeshifts last the longest.


In reply to Re: Writing to command line when prompted by Aristotle
in thread Writing to command line when prompted by Mahoota

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.