This is a good point. I will test it. If my memory is
correct you are supposed to use || for numeric expressions
and or for words. If I had a vote left today I would give
you a point. :) | [reply] |
|| and "or" (as well as && and "and") have nothing to
do with numeric vs strings. They both are simple
tests, the only difference is in their priority: the
"words" ("and" and "or") are of a lower priority
than the ones a C programmer would know (&& and ||).
'or' is safer to use in some cases because it almost
guarantees that everything to the left of it binds
tighter (gets evaluated as a single expresion) and
*then* gets tested. It's really on a case by case basis. A
good and consistent use of parenthesis can often prevent
making such decisions, as it removes the the precedence
ambiguity.
| [reply] |
Sorry, but your memory is incorrect here. :)
I think you're probably confusing the difference between
or and || with the difference between, say, lt and <.
There is no relationship between the two differences.
or and || act the same (they have the same short-circuit
behavior), but or has a much lower precedence--meaning
that you can use it after list operators without using
parantheses. Read perlop for more details.
| [reply] |