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

Torsten Seemann torsten.seemann at infotech.monash.edu.au
Thu Aug 24 18:23:43 EDT 2006


> @scores = ('x1', 'x2', 'x3', 'xn')
> Where x1, x2...xn are the score values and n is the number of elements
> in the array;

Although this is not really a Bioperl question, I feel I should mention 
this solution:

use List::Util qw(sum);
@scores = (1,2,3,4,5);
print sum(@scores);

The List::Util module is part of the standard Perl distribution and is 
likely to have an optimized implementation.

-- 
Dr Torsten Seemann               http://www.vicbioinformatics.com
Victorian Bioinformatics Consortium, Monash University, Australia



More information about the Bioperl-l mailing list