General comments:

Line 3 should be line 1. And it should be uncommented. A use warnings; as line 2 would be good as well. Together these two lines will help you find more problems in your Perl code than just about anything else ever could.

Line 20 should be before line 11. And, given what you are asking, it should probably read Getopt::Long instead of Getopt::Std. (By the way, that's the answer to your direct question: Getopt::Long can do everything you ask.)

Exception to the above: While you can make multiple logfile arguments, I'd rather use the <> operator, and have the script take a list of filenames on standard input. (Which also lets it read from a pipe instead. Very useful if you decide to start compressing these files, or only want to process certain lines...)

Learn POD, and use it (and Pod::Usage) instead of trying to format your own helptext. It's much harder to do right than you'd think. POD makes it easy.


In reply to Re: passing command line arguements to perl script by DStaal
in thread passing command line arguements to perl script by namishtiwari

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.