if statements test a control statement to see whether it is true or false.
else and elsif clauses can also be tagged on the back.
#your basic if
if($value==1){
print "value is equal to 1\n";
}
#your basic if/else
if($value==1){
print "value is equal to 1\n";
} else{
print "value is not equal to 1\n";
}
#your basic if/elsif/else
if($value==1){
print "value is equal to 1\n";
} elsif($value==2){
print "value is equal to 2\n";
} elsif($value==3){
print "value is equal to 3\n";
} else{
print "value is not equal to 1,2, or 3\n";
}
Unless statements offer you the opposite functionality. If the control statement evaluates
to false then the statements inside the block are executed.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|