Im taking a perl class not exactly sure if what Im doing is right.
I was to take a written program that allowed the user to enter a number guessing what the target was. The original used elseif statements to let the user know if the guess was to high, too low, or correct. I need to make it so that it loops until the correct answer is given. Here is what I have so far. Any suggestions would be great.
#!/usr/bin/perl -w
# guessnum2.pl
use strict;
my $target = 12;
print "Guess my number!\n";
print "Enter your guess: ";
my $guess = <STDIN>;
if ($target == $guess) {
print "That's it!! You guessed correctly:\n";
while (<STDIN> > $target) {
print "Your guess is too high!\n";
}
while (<STDIN> < $target) {
print "Your guess is too low!\n";
}