print "Enter your guess (1-3): ";
$guess = <STDIN>;
BLOCK: { # start of bare block
if ( $guess == 1 ) {
print "Right!\n";
last BLOCK; # jump to end of BLOCK
}
if ( $guess == 2 ) {
print "Close!\n";
last BLOCK; # jump to end of BLOCK
}
if ( $guess == 3 ) {
print "Wrong!\n";
last BLOCK; # jump to end of BLOCK
}
# default case;
{
print "Please re-enter your guess (1-3): ";
$guess = <STDIN>;
redo BLOCK; # jump to beginning of BLOCK
}
}
|