26
Personally, I would use Math::BigFloat (or BigInt) for anything that is going to touch infinity of NaN.
Why reinvent the wheel with a hack solution when there are already modules that do the job?
Use Data::Float from CPAN. It exports the following functions:
float_is_infinite()float_is_nan()And contrary to the others half-working solutions posted here, it has a testsuite.