my $sum = 0; for (my $i = 0; $i < @change; $i++) { $sum += $change[$i] * $numberofshares[$i]; }