As the saying goes, "It depends."

@ARGV contains a list of command line arguments that the user included when invoking your script.

Getopt::Long is the core module most commonly (and wisely) used for handling command line arguments.

The <> IO operator (see perlop), known as the "null filehandle" allows your script to take input either from STDIN, or from the list of files the user enumerated on the command line while invoking your script. Internally it gets this information from @ARGV.

And then there's always command line indirection.

For example, if you have a script designed to read from STDIN, you could instead invoke it with command line indirection like this:

myscript.pl <filename.txt

That method also works for output. If you want your script to print to a file instead of to the screen, you can type:

myscript.pl >outfile.txt

Those last two examples are operating system dependant, so you'll need to check your OS's documentation to gain info on specifics.

Hope this helps...


Dave


In reply to Re: how to access the commandline arguments? by davido
in thread how to access the commandline arguments? by Anonymous Monk

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.