detect a scalar

hi, is there a way to detect a scalar whether it contains numbers or char?

thx

kitweiAsked:
Who is Participating?
 
scudwebCommented:
number:
if ($yourscalar=~ /\d/)
{
}

char:
if ($yourscalar=~ /\w/)
{
}
0
 
ozoCommented:
perldoc -q "How do I determine whether a scalar is a number/whole/integer/float"
0
 
kitweiAuthor Commented:
I don't have access to try the code until monday, and I must try it that day. I promise I will respond.
Thank you very much.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
PC_User321Commented:
Hi kitwei,
This question is a repeat of question Q_10300771, which was asked (and answered) before this one appeared.

What test do you want to do on the data?
ozo and I assumed you wanted to know whether or not it _was_ a number, and scudweb assumed you wanted to know if it contained a digit (0-9) anywhere within it.
e.g. my test would regard "1234" and "12  34" as different, but scudweb's test would regard them as the same.
0
 
PC_User321Commented:
I have though of a better example
   "1234" and ">/34".
0
 
kitweiAuthor Commented:
don't worry, I'll try all cases, I'm learning Perl, so I don't mind getting more info and giving away pts
0
 
kitweiAuthor Commented:
great, thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.