@array = (1, 2, 3); $running_sum = 0; foreach $element (@array) { $running_sum += $element; } print "Total = $running_sum";