Well given that your posted code does not work (does not compile and is logically incorrect), this is similar, efficient and working:
$initValue = 2; $step = 3; $numOfMembers = 5; $str = '2 5 8 11 14'; my $str = $initValue; for my $member (1..$numOfMembers-1) { $str .= ' ' . ($initValue + $member*$step); } print $str, $/; $str = join ' ', map{ $initValue+$step*$_ } 0..$numOfMembers-1; print $str, $/;
cheers
tachyon
In reply to Re: String manipulation
by tachyon
in thread String manipulation
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |