more useful options | |
PerlMonks |
is_numericby tlm (Prior) |
on Apr 11, 2007 at 20:49 UTC ( [id://609478]=CUFP: print w/replies, xml ) | Need Help?? |
A simple way to test for numeric values. It basically asks perl whether it thinks the argument is numeric, by testing whether the argument is "numerically equal" to itself, and trapping any errors. Update: Dang! I guess one could add !ref($x) && to the last line, but the joy is gone... Update 2: Thanks Fletch; Scalar::Util::looks_like_number is the way to go.
Back to
Cool Uses for Perl
|
|