RE: String To Number Conversion

2004-11-23 Thread ext-Chetak.Sasalu
Hi ,

You do not need a atoi function in Perl. All the strings can be used as a 
number based on the context.

for example

$str1 = '50';
$str2 = '2';

$sum = $num1 + $num2; # sum is now 52

$str_cat = $num1.$num2; #str_cat is 502


HTH,
Chetak




-Original Message-
From: A Madhusudan-A5324C [mailto:[EMAIL PROTECTED]
Sent: Friday, 18. June 2004 14:34
To: Perl List
Subject: String To Number Conversion


Hi All,

Does anyone know how to convert string into Number in Perl. Just like the 
classic atoi function of C.
Thanks a lot in advance

Madhusudan

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



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




Re: String To Number Conversion

2004-06-18 Thread Paul Johnson
On Fri, Jun 18, 2004 at 06:03:34PM +0530, A Madhusudan-A5324C wrote:

> Does anyone know how to convert string into Number in Perl. Just like
> the classic atoi function of C.

Yep.  perl does.

If you want something to be a number, use it as one.

$ perl -le '$a = "0.36"; $b = "2.456e3 or so"; $c = $a + $b; print $c'
2456.36

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




String To Number Conversion

2004-06-18 Thread A Madhusudan-A5324C
Hi All,

Does anyone know how to convert string into Number in Perl. Just like the classic atoi 
function of C.
Thanks a lot in advance

Madhusudan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]