|
|
Perl IF ELSE Conditional Control Function
|
Tutorials

Perl

|
Topic |
What is If else Conditional Control function in Perl programming?
|
|
Explanation |
|
The If else function in Perl is a conditional control statement, where a set of statement is executed based on a condition.
Syntax:
if (expr1)
{
Statement to be executed
}
else
(
Statement to be executed
)
In the above syntax a set of statement is executed if "expr1" is true, else a different set of statement is executed that is after the else statement.
Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
$a = "HIOX";
$b = length($a);
if ($b== 1)
{
print "The string has one character\n";
}
else
{
print "The string has many characters\n";
}
Result:
The string has many characters
In the above example the length of a string "HIOX" is checked and the appropriate result is displayed
as the length of the string is not 1.
|
|
A Note |
|
Simple introduction, basic CGI perl programming codes with examples.
Do send your feedback or suggestions on this tutorial.
This is a copyright content.
|
|
|
|