Andrew Gaffney wrote:
>
>Steve Gilbert wrote:
>> I know there must be a way to do the following:
>> 
>> if (($foobar > 3) || ($foo="t" && $bar = "b")) {print
>> "yup"}
>
>if (($foobar > 3) || ($foo eq "t" && $bar eq "b")) {print "yup"}
>
>Your problem is that a single '=' is assignment, not equality. '==' could
also be used 
>instead of 'eq'.

Actually, no, '==' could not be used.  Witness this code:

$abc="b";
print "yes\n" if ($abc=="b");  # appears that == works
print "yes\n" if ($abc=="e");  # shows that == does not work

Output:
yes
yes

To do string comparisons, you must use 'eq', 'ne', etc.

$abc="b";
print "yes\n" if ($abc eq "b");  # appears that 'eq' works
print "yes\n" if ($abc eq "e");  # and indeed it does

Output:
yes


HTH
Alan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to