On Fri, Nov 09, 2001 at 04:10:31PM +0000, Richard Smith wrote:
> This seems such an obvious operation, but the syntax
> escapes me. I have an array of up to 6 values, which I
> want to add together. I am sure there must be a
> shorthand version of this:
> 
> $result = @array[0] + @array[1] + @array[2] +
> @array[3] + ...etc

@ary = (1,4,7);
$sum += $_ for @ary;
print $sum;

regards,
/Martin



Reply via email to