Edward:

What you have there is an array with only one scalar element (an array
reference containing 3 values). Note that $array[1] & $array[2] would be
undefined in your example. I think what you intended was to do:

@array = ('1','2','3'); # An array containing three elements, '1', '2',
'3'
(Or more simply: @array = (1..3); )

With regards to switching between string & numeric values, perl will do
this automagically for you. You can just perform whatever math you want
as per normal. Consider the following:

@array = ( '1', '2', '3');
print $array[0] + 1;

Output: 2

Hope this helps.

Matt Shaw
http://www.thinktechnology.ca/

> -----Original Message-----
> From: Edward WIJAYA [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 14, 2004 10:12 PM
> To: [EMAIL PROTECTED]
> Subject: String to Numeric of an Array
> 
> Hi,
> 
> How can I change the value of this array:
> 
> @array = ['1','2','3']; #which contain "string" numeric
> 
> to
> 
> @arrayNum = [1,2,3];  #as pure numeric
> 
> Regards,
> Edward WIJAY
> 
> --
> 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>


Reply via email to