Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VERY SIMPLE QUESTION NEED HELP FAST

Status
Not open for further replies.

mike101

Programmer
Jul 20, 2001
169
US
Hi, I need to know how to make a "or" statement after an if statement. What I mean is I have it like below but dont know what to replace "or" with.

if ($editing2 eq 'baseballhba') or ($edit eq 'baseballhba') {

Please help me I need to have this done in 45 min.
 

use the double pipe operator || as so:

if ($editing2 eq 'baseballhba' || $edit eq 'baseballhba') {
#code here
}

Matt.
 
There shouldn't be that much difference between the two. Perl does have an "or" operator, as well as the "||" operator. Supposedly the only difference between the two is how tightly they "bind". In a case like this either one should work. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
the condition *MUST* be enclosed by parenthesis...


so if you still want to use or (I use the doble-pipe) do this:

if ( ($bla eq 'bla') or ($ble eq 'ble) ) {
# BLABLABLABLA
}
 
SpiceMan - get yourself a Tek-Tips userid, then we can give you a TipMaster "Star" for answers like that :) Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
SpiceMan: you're correct, of course. That's what I meant about the way the two different or operators "bind". In the one case it apparently binds more tightly even than the "eq", so you need the parens to make it work the way you want. I usually use the || version too, but thought I'd make an educational point. I probably just confused the issue more, but sooner or later people are bound to run across the "or" operator in someone else's code and wonder about it. I also usually use the parens around the parts of the condition even with the || operator. It never hurts to do that.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks everyone. All of the wayss worked. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top