Perl Topics





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Perl Tutorial
Introduction Introduction
Installing Perl Installing Perl
Basics of Perl Basics of Perl
Scalar Variables Scalar Variables
Operators Operators
Control Structures Control Structures
Lists Lists
Array Array
Arrays Manipulation Arrays Manipulation
Arrays Functons Array Functions
Hash Hash
Hash Functions Hash Functions
String Functions String Functions
Regular Expression Regular Expression
Regular Expression Functions Regular Expression Functions
Numerical Functions Numerical Functions
List Functions List Functions
User Defined Function User Defined Function
File Handling File Handling
Forums Ask Your Doubts
Feedback Feedback
 





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.

Other Links

web hosting