Link to home
Start Free TrialLog in
Avatar of shivaki
shivaki

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of guadalupe
guadalupe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shivaki
shivaki

ASKER

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
$num_of_chrs = length($value);
Avatar of shivaki

ASKER

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
Just in case you missed this comment I'll put it again:

$num_of_chrs = length($value);
Avatar of shivaki

ASKER

Thanks a lot!.