Because == evaluates 'a' in numeric context. eq is used for alpha comparisons, but it will never match because $select still has a newline character (\n) appended from the input.
Outputs:#!/usr/bin/perl use warnings; use strict; print "what is your name: "; chomp( my $name = <STDIN> ); print "hello $name\n"; print "select letter\n"; chomp( my $select = <STDIN> ); if ($select eq 'a'){ print "good choice\n"; } else { print "bad choice\n"; }
what is your name: steve hello steve select letter a good choice
In reply to Re: What i doing wrong
by stevieb
in thread What i doing wrong
by MSPM5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |