
Karazam
User
Mar 13, 2011, 8:45 AM
Post #2 of 14
(1014 views)
|
|
Re: [senca] Comparing string variables doesn't work
[In reply to]
|
Can't Post
|
|
Well, you are saving the guess in $guess, but try to compare with $choice. With "use warnings;" perl would have warned you that $choice only occurs once. You also need to have a "chomp $guess;" to remove it's newline character. Instead of the foreach loop, I would suggest
if ( grep {$_ eq $guess} @chars ) { print "roko"; } else { print "nope"; } Hope this helps.
(This post was edited by Karazam on Mar 13, 2011, 8:53 AM)
|