[Top] [All Lists]

RE: variable help

Subject: RE: variable help
From: Andrew Curry
Date: Tue, 4 Mar 2008 20:51:59 -0000
Newsgroups: perl.beginners

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

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: [email protected]
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: [email protected]
Subject: Re: variable help


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

To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

This e-mail is from the PA Group.  For more information, see
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.

<Prev in Thread] Current Thread [Next in Thread>