in reply to Re: Better way to search array for elements in other array?
in thread Better way to search array for elements in other array?

First, you should use > instead of ge when dealing with numerical values

Well, ">=" would be the numerical equivalent to the string comparison operator "ge", so index(...) >= 0 would be perfectly fine.

The reason the string comparison operators are not suitable for numerical comparisons is that they don't use different rules than the numerical comparison operators.

$ perl -E'say 2 >= 10 ? 1 :0' 0 $ perl -E'say 2 ge 10 ? 1 :0' 1 # Because 2 ge 1

Replies are listed 'Best First'.
Re^3: Better way to search array for elements in other array?
by Limbic~Region (Chancellor) on Jan 24, 2011 at 21:30 UTC
    ikegami,
    Well, ">=" would be the numerical equivalent

    You took that out of context. I also changed the 0 to a -1 which made > appropriate. Regarding the explanation for string operators versus numerical operators, I thought a pointer to perlop sufficient.

    Cheers - L~R

      I was telling the OP that he didn't need to do such a change, so it was hardly out of context.
        ikegami,
        I was telling the OP

        My apologies. When you responded to my node and didn't specifically address the OP, I assumed the response was directed at me.

        Cheers - L~R