Be warned though that int isn't cleaver enough to deal with say...

$x='0';
print int($x);

still says it's a string as It is.

If you are not 100% sure then you can also do if ($x =~/^\d*$/) for an
actual integer i.e. a number in the positive whole set of numbers {
1,2,3....}  or negative whole numbers -1,-2,-3.... or 0. 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 04 March 2008 20:42
To: [EMAIL PROTECTED]
Cc: beginners@perl.org
Subject: RE: variable help

Thanks Brown. It worked.


-----Original Message-----
From: Rodrick Brown [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 05, 2008 1:50 AM
To: Sayed, Irfan
Cc: beginners@perl.org
Subject: Re: variable help

#!/usr/bin/perl

my $p = 10;

if( int($p) ) {
  print "$p is an interger\n";
}
~


On Tue, Mar 4, 2008 at 3:16 PM,  <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>
>
> How to find out the specific variable contains integer value. In my
> script ,variable is storing some value but I want to find out whether
> that value is string or integer.
>
>
>
> Please help
>
>
>
> Regards
>
> Irfan.
>
>



-- 
Rodrick R. Brown
http://www.rodrickbrown.com
http://www.linkedin.com/in/rodrickbrown

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


This e-mail is from the PA Group.  For more information, see www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise use this 
email or any attachments.  
If you have received it in error, please contact the sender immediately.  
Any opinion expressed in this e-mail is personal to the sender and may not 
reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or monitoring 
for operational reasons or for lawful business practices.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to