Perl: If Else

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
Submitted by programmer on Thu, 04/15/2010 - 12:08.
::

Conditional statements may involve logical operators (Perl if else) and usually test equality or compare one value to another.

Here's a look at some common Perl If Else conditional statements.

#!/usr/bin/perl
 
$city="London";
 
if ($city eq "Paris") {
print "The city is Paris. ";
}
elsif ($city eq "Tokyo") {
print "The city is Tokyo. ";
}
else {
print "The city is London. ";
}

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.