Solved

detect a scalar

Posted on 2000-02-24
7
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

623 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