Cyber Sentry
Application Development
System Architecture Design
Technical Due Diligence
Qmail Support and Consultancy
Scripting Help
Partners
Client Testimonials
Help Sections
Software Patents
Site Map
Contact us
Community
Home

Conditionals

Of course Perl also allows if/then/else statements. These are of the following form:

 

if ($a)

{

print "The string is not empty\n";

}

else

{

print "The string is empty\n";

}

 

For this, remember that an empty string is considered to be false. It will also give an "empty" result if $a is the string 0.

 

It is also possible to include more alternatives in a conditional statement:

 

if (!$a) # The ! is the not operator

{

print "The string is empty\n";

}

elsif (length($a) == 1) # If above fails, try this

{

print "The string has one character\n";

}

elsif (length($a) == 2) # If that fails, try this

{

print "The string has two characters\n";

}

else # Now, everything has failed

{

print "The string has lots of characters\n";

}

 

In this, it is important to notice that the elsif statement really does have an "e" missing.



Qmail Help Section
Perl Tutorial
Linux Command Line Help
Top top Copyright Cyber Sentry Ltd  

Cyber Sentry -- Application Development Sitemap 1 2 3