in reply to Basic Times Table excercise
Once the while loop is left, you know the answer was correct (as that's the condition to exit the loop). You need to check for the wrong answer inside the loop:
while (1) { chomp( my $answer = <STDIN> ); if ($answer eq $x) { print "Great, $answer is correct.\n"; print "Hit enter to continue, Ctrl+C to exit."; <STDIN>; last } else { print "Sorry, $x is not correct, please try again.\n"; } }
Why do you use the string comparison eq instead of the numeric == ?
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Basic Times Table excercise
by jibberjabber (Novice) on Feb 17, 2016 at 01:59 UTC |