5

Possible Duplicate:
How do I create or test for NaN or infinity in Perl?

How can I check, if scalar holds inf value?

I check NaN as $scalar != $scalar, what to do with inf?

$scalar == inf does not work, since inf is a bareword

Community
  • 1
  • 1
Karel Bílek
  • 36,467
  • 31
  • 94
  • 149

2 Answers2

0

you can use this to check for infinity:

$scalar < 9**9**9

that constant is so large that it will be interpreted as infinite by Perl

Eric Strom
  • 39,821
  • 2
  • 80
  • 152
-1

I found a dirty hack right now.

($scalar eq "inf")

Does anything cleaner exist?

Karel Bílek
  • 36,467
  • 31
  • 94
  • 149
  • 1
    Not good. Perl will stringify inf however the underlying libc does, and that can vary (both within the C standard and, on Windows, far outside it). – ysth Feb 14 '10 at 04:22