develooper Front page | perl.beginners | Postings from February 2002

RE: convert array to integer

Thread Previous | Thread Next
From:
John Edwards
Date:
February 22, 2002 04:18
Subject:
RE: convert array to integer
Message ID:
2FB59B145095D511A7C90050BAC349F317328C@MAIL
$num=$num-0;

You don't need to do this in Perl. There is no distinction between an
integer and a string. It's just a scalar. <OT>This is something you would
have to do in Javascript though.</OT>

John

-----Original Message-----
From: walter valenti [mailto:waltervalenti@yahoo.it]
Sent: 22 February 2002 12:12
To: kitti
Cc: beginners@perl.org
Subject: Re: convert array to integer


kitti wrote:

>how to convert array to integer
>
>$array[0]=5
>$array[1]=6
>$array[2]=7
>$array[3]=8
>
>change to integer 5678 for calculate 5678+2=5680
>
>thanks,
>
In not much elegant...

foreach(@array){
    $num.=$_;
}

$num=$num-0;



    Walter



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About