Perl IF ELSE- If Statement - Perl Scripting

What is Perl if Statement? What is its function?

A Perl if statement consists of a boolean expression that is two conditions followed by one or more statements.


The syntax of an if statement in Perl programming language is −
If the boolean expression evaluates to true then the block of code inside the if statement will be executed. If boolean expression evaluates to false then the first set of code after the end of the if statement (after the closing curly brace) will be executed.
The number 0, the strings '0' and "" , the empty list () , and undef are all false in a boolean context and all other values are true. Negation of a true value by ! or not returns a special false value.
Flow Diagram


First IF statement uses less than operator (<), which compares two operands and if first operand is less than the second one then it returns true otherwise it returns false. So when the above code is executed, it displays the following result −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Perl Scripting Topics