in reply to Re^2: Exploiting Perls idea of what is a number (oops)
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). :)

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

-- 
Ronald Fischer <ynnor@mm.st>
  • Comment on Re^3: Exploiting Perls idea of what is a number (oops)

Replies are listed 'Best First'.
Re^4: Exploiting Perls idea of what is a number (oops)
by tye (Sage) on Jul 08, 2008 at 15:22 UTC

    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        

Re^4: Exploiting Perls idea of what is a number (oops)
by ikegami (Patriarch) on Jul 09, 2008 at 04:15 UTC
    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>