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.

Syntax

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
if_statement

Example

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 −


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Perl Scripting Topics