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

Re: convert array to integer

Thread Previous | Thread Next
From:
John W. Krahn
Date:
February 22, 2002 04:50
Subject:
Re: convert array to integer
Message ID:
3C763EB5.206B7BA4@acm.org
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


$ perl -le'
@array = qw(5 6 7 8);
print 5678 + 2;                             
print join( "", @array ) + 2;
'
5680
5680


John
-- 
use Perl;
program
fulfillment

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