-----Original Message-----
From: tom arnall [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 20, 2006 12:08 PM
To: [email protected]
Subject: Re: how to add a list of numbers
>
<snip>
>
> Whatever happened to good old:
>
> my (@data,$result);
> @number = (1,2,3);
> $sum = 0;
> foreach(@number) {
> $sum += $_;
> }
>
> I think we should use this kind of algorithm in answer to a newbie's
> question.
> Or have I, learned colleagues, missed something?
Good call. I think there has been substantial over-engineering of the problem.
I would only alter it slightly to make the snippet strict-compliant and for
clarity:
#######################
use strict;
use warnings;
my @numbers = (1,2,3);
my $sum = 0;
foreach my $number(@numbers){
$sum += $number;
}
#######################