in reply to how to enable, disable strict
In your example if the secret number was 42 and the user enters 43 they are not told that they have failed to guess correctly.use strict; use warnings; my $secret=42; my $guess; while(1) { print "please enter a guess from 1 to 100: "; chomp($guess = <STDIN>); if ($guess =~ /quit|exit|^s*$/i){ print " sorry you gave up.the number was $secret.\n"; last; } if ($guess != $secret) { print "Wrong! Guess again.\n"; }else{ print "Correct!\n"; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to enable, disable strict
by elsiddik (Scribe) on Apr 25, 2007 at 10:20 UTC | |
by GrandFather (Saint) on Apr 25, 2007 at 10:37 UTC | |
by elsiddik (Scribe) on Apr 25, 2007 at 10:58 UTC |