PERL TUTORIALS - Perl IF...ELSE
Perl IF...ELSE
ADVERTISEMENTS
Statement | Description |
---|---|
if statement | An if statement consists of a boolean expression followed by one or more statements. |
if...else statement | An if statement can be followed by an optional else statement. |
if...elsif...else statement | An if statement can be followed by an optional elsif statement and then by an optional else statement. |
unless statement | An unless statement consists of a boolean expression followed by one or more statements. |
unless...else statement | An unless statement can be followed by an optional else statement. |
unless...elsif..else statement | An unless statement can be followed by an optional elsif statement and then by an optional else statement. |
switch statement | With latest versions of Perl, you can make use of switch statment which allows a simple way of comparing a variable value against various conditions. |
ADVERTISEMENTS
The ? : Operator
Exp1 ? Exp2 : Exp3;ADVERTISEMENTS
#!/usr/local/bin/perl $name = "Ali"; $age = 10; $status = ($age > 60 )? "A senior citizen" : "Not a senior citizen"; print "$name is - $status\n";