|
|
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: Irfan.Sayed@xxxxxxxxxxxxx [mailto:Irfan.Sayed@xxxxxxxxxxxxx]
Sent: 04 March 2008 20:42
To: rodrick.brown@xxxxxxxxx
Cc: beginners@xxxxxxxx
Subject: RE: variable help
Thanks Brown. It worked.
-----Original Message-----
From: Rodrick Brown [mailto:rodrick.brown@xxxxxxxxx]
Sent: Wednesday, March 05, 2008 1:50 AM
To: Sayed, Irfan
Cc: beginners@xxxxxxxx
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, <Irfan.Sayed@xxxxxxxxxxxxx> 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: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
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.
|
|