I decided to test your assertion that use strict;use warnings; would not help this OP. When I ran the OP's code with strict and warnings after adding 'my' where needed I got the following:

Bareword "a" not allowed while "strict subs" in use at 962926.pl line +10. Execution of 962926.pl aborted due to compilation errors.

That is one thing it would have helped with. So I added quotes to get the code below. Have a look at the warnings I got then. Clearly would have been helpful. Probably a 'good choice'.

#!/usr/bin/perl use strict; use warnings; print "what is your name\n"; my $name = <STDIN>; print "hello $name"; print "select letter\n"; my $select = <STDIN>; if ($select == 'a') { print "good choice\n"; } else { print "bad choice\n"; }
Argument "a" isn't numeric in numeric eq (==) at 962926.pl line 10, <S +TDIN> line 2. Argument "a\n" isn't numeric in numeric eq (==) at 962926.pl line 10, +<STDIN> line 2. good choice

In reply to Re^3: What i doing wrong by Lotus1
in thread What i doing wrong by MSPM5

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.