How do I multiply each member of array by a scalar in perl?
Use foreach.
foreach my $x (@array) { $x = $x * $scalar; }
You can try this:
@array = map { $_ * $scalar } @array;
or more simply:
map { $_ *= $scalar } @array;
Use foreach.
foreach my $x (@array) { $x = $x * $scalar; }
You can try this:
@array = map { $_ * $scalar } @array;
or more simply:
map { $_ *= $scalar } @array;