Else if
Alternatively referred to as elsif, else if is a conditional statement performed after an if statement that if true performs a function. Below is an example of an if, elsif, and else conditional statement in Perl.
#!/usr/bin/perl
print "Enter number: ";
my $number = <STDIN>;
if ($number <= 10) {
print "Your number is less than or equal to 10";
}
elsif ($number <= 50) {
print "Your number is more than 10, but less than 50";
}
else {
print "Your number is greater than 50";
}
The above example shows how elsif could be used to create an additional conditional statement and not just a simple if or else statement. This could also be extended adding as many elsif or else if statements as the program needed.
Not all programming languages are the same, although this above example used elsif, in a different language such as ANSI C you would use else if.
Also see: Conditional statement, Else, If statement, Programming definitions
