Number-Zero reviews

RSS | Module Info

Number-Zero (0.02)

From the module's POD: "The number zero and undef are difficult to determine in Perl."

Are they?

say !defined($data) ? "undef" : "not undef";

say defined($data) && $data==0 ? "zero" : "not zero"; # yes, warn if non-numeric

use Scalar::Util 'looks_like_number';
say looks_like_number($data) && $data==0 ? "zero" : "not zero";

Though I understand the need for a convenient "is_zero" function if you need to test for zero in a program a lot.

Number-Zero (0.02) *

This is a misguided module that doesn't even do what it says it does. It only tests if a value is defined and false, not if it is actually numerically equal to 0. Also it's sloppily coded so it will issue a warning if passed undef as an argument.