Solved

detect a scalar

Posted on 2000-02-24
7
342 Views
Last Modified: 2010-05-18
hi, is there a way to detect a scalar whether it contains numbers or char?

thx

0
Comment
Question by:kitwei
7 Comments
 

Accepted Solution

by:
scudweb earned 50 total points
ID: 2556526
number:
if ($yourscalar=~ /\d/)
{
}

char:
if ($yourscalar=~ /\w/)
{
}
0
 
LVL 84

Expert Comment

by:ozo
ID: 2556589
perldoc -q "How do I determine whether a scalar is a number/whole/integer/float"
0
 

Author Comment

by:kitwei
ID: 2556862
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 5

Expert Comment

by:PC_User321
ID: 2561079
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
 
LVL 5

Expert Comment

by:PC_User321
ID: 2561087
I have though of a better example
   "1234" and ">/34".
0
 

Author Comment

by:kitwei
ID: 2561519
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
 

Author Comment

by:kitwei
ID: 2566641
great, thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question