Hi,

Usage: ./exer_9_2 filename at ./exer_9_2 line 7.
What is this current error telling me?

You're obviously serious about learning to program, so you'll want to start more becoming pedantic right away :-)

That's not an error, that's a message. The error was when you pressed [Enter] after only typing "./exer_9_2".

The message is being emitted by the die command on line 7. The message tells you that fact, with its last part "at ./exer_9_2 line 7" showing filename and line. Perl is just that awesome.

The first part of the message is whatever the die command caused to be emitted. In this case, it's the value of the expression Usage: $0 filename. Hopefully you know (since you put it in your code) that $0 resolves to the current filename. So that's why the message names the file twice.

Knowing all that, you might decide to produce cleaner output, and not die, but just exit instead.

if (! defined $in) { print "Usage: $0 <filename>\n"; exit(1); }
(Note the use of the convention of placing an example value for an argument inside angle braces.)

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re^2: First attempt at bringing in file for input/output by 1nickt
in thread First attempt at bringing in file for input/output by catfish1116

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.