--------------------------
#!/usr/bin/perl
use CGI;
print "Content-type:text/html\n\n";
$str="phi";
if($str eq "phi")
{
print "Phi. ";
}
if($str eq "phiq")
{
print "Phiq! ";
}
else
{
print "OTHERWISE! UNFORTUNATELY, Phi. is printed to the left of this!";
}
if(condition)
{
code block
}
else if(condition)
{
code block
}
else if(condition)
{
code block
}
else(condition)
{
code block
}
Might work for you. I am not clear what you are trying to accomplish. Else only exists in conjunction with an if statement, so of course it is going to be joined with the last if the way you have it written.
WBF
if($str eq "phi")
{
print "Phi. ";
}
elsif($str eq "phiq")
{
print "Phiq! ";
}
else
{
print "OTHERWISE! UNFORTUNATELY, Phi. is printed to the left of this!";
} ..this will group both "if" tests together so that if _both_ the first and second tests (both of the "ifs") are not true (not equal) only then will the "else" clause be executed. As you had it before the "else" only applied to the second "if".