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

RE: convert array to integer

Thread Previous | Thread Next
John Edwards
February 22, 2002 04:11
RE: convert array to integer
Message ID:
You want to take a sum of all the array elements??

You don't need to convert the array to an interger. Perl handles this
internally. For instance, if you want to treat a text string as a number, or
a number as a text string, perl allows it.

This does what you are after

use strict;
my @array = qw(5 6 7 8);
my $total;
foreach (@array) {
	$total .= $_;

$total += 2;

print $total;



-----Original Message-----
From: kitti []
Sent: 22 February 2002 11:47
Subject: convert array to integer

how to convert array to integer


change to integer 5678 for calculate 5678+2=5680


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About