Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Perl/Basics/Boolean Logic/Statements/If"
From NetSec
AlizaLorenzo (Talk | contribs) (Created page with "An '''if''' statement may have 3 types of clauses: '''if''','''elsif''', and '''else'''. For the below example, assume that the $age scalar is passed as a command line argument: ...") |
Chantal21I (Talk | contribs) |
(No difference)
|
Latest revision as of 01:13, 19 July 2012
An if statement may have 3 types of clauses: if,elsif, and else. For the below example, assume that the $age scalar is passed as a command line argument:
if (int($age) == $age) { #Making sure it's an integer. if ($age < 18) { #If the age is less than 18: print "You must be at least 18 to view this.\n"; } elsif ($age < 21) { # If the age is more than 18, but less than 21: print "Because you are under 21, some features may be restricted.\n"; } else { # If none of the conditions have been met: display_content(); } } |