No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The really obvious way to do it is to make sure that the scalar doesn't contain a non-numeric character.
You need the initial check to make sure that $var actually contains something, otherwise the !~ will trigger a warning about unitialized variables. So, you can code up a neato little function, sorta like: Then, put that into a module of yours and have that module inherit from Exporter and you're all good! :) (Yes, I'm sure someone's already done this, but this was too cool an opportunity to promote module use. *blush*) ------ Vote paco for President! In reply to Re: Checking whether a $var is a number
by dragonchild
|
|