How do I tell if a variable has a numeric value in Perl?

前端 未结 14 1434
别那么骄傲
别那么骄傲 2020-11-28 06:56

Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:

if (is_number($x))
{ ... }
         


        
14条回答
  •  旧巷少年郎
    2020-11-28 07:21

    I don't believe there is anything builtin to do it. For more than you ever wanted to see on the subject, see Perlmonks on Detecting Numeric

提交回复
热议问题