programming-examples/perl/Statement/Using if statement to check the number entered from keyboard.pl

21 lines
405 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
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";
exit;
}
if ($guess > $target) {
print "Your number is more than my number\n";
exit;
}
if ($guess < $target){
print "Your number is less than my number\n";
exit;
}