I am trying to: Populate 10 elements of the array with the numbers 1 through 10. Add all of the numbers contained in the array by looping through the values contained in the array.
For example, it would start off as 1, then the second number would be 3 (1 plus 2), and then the next would be 6 (the existing 3 plus the new 3) This is my current code
#!/usr/bin/perl
use warnings;
use strict;
my @b = (1..10);
for(@b){
$_ = $_ *$_ ;
}
print ("The total is: @b\n")
and this is the result
The total is: 1 4 9 16 25 36 49 64 81 100
What im looking for is:
The total is: 1 3 6 10 etc..