- Perl ›
- builtin functions ›
- here
looks_like_number function - determines whether it is a number
Use the looks_like_number function of the Scalar::Util module to determine if it is a number.
use Scalar::Util 'looks_like_number'; my $ret = looks_like_number $num;
Note that in Perl, whether it's a number or a string is determined by what it looks like. Determining that it is a number does not guarantee that the internal type is a number. You can only judge whether it looks like a number.