in reply to Re: Exploiting Perls idea of what is a number
in thread Exploiting Perls idea of what is a number

That has the large drawback of declaring that "foo" is the same as "cheesecake" (while emitting two warnings). :)

- tye        

  • Comment on Re^2: Exploiting Perls idea of what is a number (oops)

Replies are listed 'Best First'.
Re^3: Exploiting Perls idea of what is a number (oops)
by jettero (Monsignor) on Jul 08, 2008 at 13:12 UTC
    Maybe !($a cmp $b || $a <=> $b) would work... nope.

    -Paul

Re^3: Exploiting Perls idea of what is a number (oops)
by rovf (Priest) on Jul 08, 2008 at 14:50 UTC
    That has the large drawback of declaring that "foo" is the same as "cheesecake" (while emitting two warnings). :)

    In my particular application, a foo is indeed the same than a cheesecake!

    -- 
    Ronald Fischer <ynnor@mm.st>

      Then use $a == $b. The $a eq $b || is just obfuscation. The only thing it changes is that it prevents warnings when given two equal, non-numeric strings (because if $a eq $b, then it will also be true that $a == $b).

      - tye        

      Then all you need is
      my $result = do { no warnings 'numeric'; $x == $y };

        I had not thought about using a do block. Thanks a lot - this is an elegant solution!

        -- 
        Ronald Fischer <ynnor@mm.st>