# suppose @myvec is an array of integers. my $sum = 0; for (my $i = 0; $i < scalar(@myvec); $i++) { $sum += 2 * $myvec[$i]; }