programming-examples/perl/Statement/A program that uses the if-elsif-else statement.pl

18 lines
557 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/local/bin/perl
print ("Enter a number:\n");
$number1 = <STDIN>;
chop ($number1);
print ("Enter another number:\n");
$number2 = <STDIN>;
chop ($number2);
if ($number1 == $number2) {
print ("The two numbers are equal.\n");
} elsif ($number1 == $number2 + 1) {
print ("The first number is greater by one.\n");
} elsif ($number1 + 1 == $number2) {
print ("The second number is greater by one.\n");
} else {
print ("The two numbers are not equal.\n");
}
print ("This is the last line of the program.\n");