Conditional Statements

The operators if and unless can be used to execute a statement conditionally.

print "a equals b\n"   if $a eq $b;
print "a is twice b\n" if $a*2 == $b;

print "a does not equal b\n"  unless $a eq $b;


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Wed Oct 11 19:01:50 EDT 2000