sum of array values...?



Hi ,I am new in Perl ,and I have to make 1 script related to
BioInformatics....
I have a for loop

for my $j(0..$#exons)
{
print "Length of value-",$exons[$j],"\n\n";
}
now whatever values are this loop is giving ,I have to get addition of
that all values and how many values it has?

Like if values are
Length of value-50
Length of value-500
Length of value-100

Output - Sum of Values-650
No. of value -3

How I can get it ? Thanks.

.



Relevant Pages

  • Re: Need help understanding how a file input block works
    ... here is a section of the Perl code that I am having ... ^ says 'match if we are at the start of the string', ... 'next' is documented in perldoc perl, in the sextion "Loop Control". ... which will stop you from using globals by accident. ...
    (comp.lang.perl.misc)
  • Re: perl newbie: leaner code ideas
    ... > To learn Perl, I have written a bit of code that needs to do the following: ... Don't declare variables prematurely. ... if the foreach loop contriol variable has already been ... variable as a foreach loop contriol variable without an explicit "my". ...
    (comp.lang.perl)
  • Re: How to avoid using the slow array subscripting operator?
    ... XL> push @res, $sum; ... perl operations for each iteration. ... loop is slow so use fewer perl ops. ... be summing the 100 lines at each possible point in the main array. ...
    (perl.beginners)
  • Re: Noob! Help required and would be really appreciated!
    ... You've read 60% of "Learning Perl"? ... On finding the keyword "New Order", it has to start building a hash. ... want to build a loop around this hash creation. ... transferred to %allOrders. ...
    (comp.lang.perl.misc)
  • Re: grep and regex
    ... Perl be smart enough to understand that the outer most pair of paranthesis and ... Perl will try to figure out what you ... foreach my $cut ... statements, without any loop. ...
    (perl.beginners)