I have an MyArray whoes content are "200 500 800 100 " in perl . I need function which return me first 200, second iteration it should return me 200+500, next time it should return me 200+500+800,until it has sumup all the elements.
foreach my $i (0 .. $#MyArray)
{
@MyArray = (1..$i);
$sum += $_ for @MyArray;
}
I am trying to do something as mentioned above, but its not returning any $sum