A couple quick housekeeping things first: There are instructions on formatting your posts immediately below the posting box, and it helps us a lot to help you if you follow them. In particular, <code></code> tags around your code fragment make it easier to read, prevent brackets from being treated as markup, and give us a "download" button which pops the code up in a new page without any inconvenient line wrapping. Also, you'll want to get in the habit of useing strict as well as warnings (you're already using warnings, since you have the -w option in your shebang line, so that's good!).

You ask if you are on the right track, but it's far more effective if you tell us what you've seen happen so far. Have you run the code? If not, why not? If so, what did you see? One thing that seems odd to me is that you allow the user to enter the file on the command line, but then still prompt them for a filename even if they give one on the command line. Another problem is that you're using the wrong version of or to do your open ... or die (you want or which has the lowest precedence, not ||, which has a higher one). I also don't see where you ever construct the tcl command itself, so it's hard to know if you're "on the right track"

There are a number of other technical quibbles with your Perl style which you may or may not be interested in (it looks like you're using some style elements that were once standard or even necessary, but are now deprecated). Unless you're stuck using a very old version of Perl, you can use scalar variables for your filehandles instead of barewords (e.g. USERINPUT), and this has a lot of advantages. Also, the 3-argument form of open is better than the 2-argument form (among other things, it helps in the case where the filename includes strange characters). There's other stuff too, but that's a good start for now.

In short, don't post a really short problem statement with a bunch of code and ask how you're doing. Post code (in appropriate tags), post the results you got from running it, or a clear statement of where you're stuck, and describe in detail what you thought it should do or don't understand why it did.


In reply to Re: How to use getopts? by ssandv
in thread How to use getopts? by mommydearest

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.