Question : perl if else
Answered by : charlesalexandre-roy
# Basic syntax:
if (condition_1) { print "condition_1 was met\n";
}
elsif (condition_2) { print "condition_2 was met\n";
}
else { print "for everything else, there's Mastercard\n";
}
# Note, some people like to shorten the syntax like this:
if (condition_1) { print "condition_1 was met\n";
} elsif (condition_2) { print "condition_2 was met\n";
} else { print "for everything else, there's Mastercard\n";}
# Example usage:
my $variable = 3;
if ($variable > 5) { print "Three is greater than 5\n";
}
elsif ($variable < -7) { print "Three is less than negative 7\n";
}
else { print "Apparently 3 falls between -7 and 5\n";
}
Source : https://www.tutorialspoint.com/perl/perl_if_elsif_statement.htm | Last Update : Fri, 11 Mar 22