[Bioperl-l] Adding all elements from an array of scores

Sendu Bala bix at sendu.me.uk
Sat Aug 19 14:11:20 EDT 2006

francois fauteux wrote:
> Having an array of alignment scores:
> @scores = ('x1', 'x2', 'x3', 'xn')
> Where x1, x2...xn are the score values and n is the number of elements
> in the array;
> How could I add the values x1 + x2 + x3 + ...xn (would have to adapt
> to arrays of variable number of elements);
> It would look like 'add $score[1] + $score[2] ... and so on until
> there is no more elements in the array';

This list is for questions relating to Bioperl, not general perl 
questions. In any case, just use a foreach loop and the + operator.

More information about the Bioperl-l mailing list