in reply to
What i doing wrong
use strict and warnings
It's not going to solve his error (not chomping).
Using strict and warnings isn't a silver bullet. In a rare case, it solves a problem. In that rare case, posting "use strict; use warnings;" is a useful answer. Most of the time, it's not.
This is a "most of the time" case.
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
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'.
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";
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.
A Programming Language, 1962
Programming the 1900 series in COBOL, 1974
Algorithms + Data Structures = Programs, 1976
The C Programming Language, 1978
System V - Interface definition, 1986
Z80 Assembly Language Programming, 1979
TheSOURCE User's Manual, 1979
The C Primer, 1983
Interactive Fortran 77, A Hands on Approach, 1984
Perl.1 man page, 1991
Results (10 votes),