How to know whtether a variable is Integer, float or a string

Hello there,
        It seems very stupid but I am facing problem with it. I am using a subroutine which retunrs either a string or an errorcode( a signed integer ) depends on the context. The problem for me is after getting the result from subroutine I have to format varius things depends on the value that I receive. if it is a string I will presents a form or else I have to tell vaious err.states.
            Speaking otherwords I have to seggreate Integers and String form ret. value from f a subroutine.
Thanks
Shivaki
shivakiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guadalupeCommented:
To test if something is an integer use:

if ($value =~ /^[+-]?\d+$/)
{
    #$value is an integer
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shivakiAuthor Commented:
Thanks guadalupe ,
          This is working fine. since it is a regular expr. it has to check each and every chanracter. the other way to tackle my problem is whenever I revceives a string its length is more than 50 chars. So I think the perf. can be slighly increased based the lenght of return value. Could you please tell how to find the length of a string without using reg expr. I am not getting any strlen() function in perl.
Thanks a lot
-shivaki
0
guadalupeCommented:
$num_of_chrs = length($value);
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

shivakiAuthor Commented:
Thanks guadalupe ,
          This is working fine. since it is a regular expr. it has to check each and every chanracter. the other way to tackle my problem is whenever I revceives a string its length is more than 50 chars. So I think the perf. can be slighly increased based the lenght of return value. Could you please tell how to find the length of a string without using reg expr. I am not getting any strlen() function in perl.
Thanks a lot
-shivaki
0
guadalupeCommented:
Just in case you missed this comment I'll put it again:

$num_of_chrs = length($value);
0
shivakiAuthor Commented:
Thanks a lot!.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.