I think we are in agreement.
I was keying on the OP's statement of the problem: "compare a value to two numbers". The proposed formulation is very, very good! I see no reason to "improve" it.
For efficiency, with a much larger set of possibilities, "does value X exist within a data set?", I would think that the List::MoreUtils qw (any); solution is the best for two reasons: a)Since it is an XS module it will run faster than native Perl code, b)the grep solution will examine all possibilities in order to return the scalar result of number of "matches" whereas a well written XS module would return true immediately upon the first match.
The Perl "or" code will also "give up" and stop processing immediately upon the first successful match (OR condition is satisfied). I think this is just fine for say 1/2 dozen "or" conditions. Of course the expected probability of returning "true" should be taken into account in the ordering of an "if" statement. This may result in faster code than using say the "smart match" operator in Perl 5.10. Benchmark the program if there is any doubt. |