in reply to Modify array elements inside for loops
(faster? maybe not, but cooler and shorter, yes =)my @new_a = map { $_+1 } @a;
Whether or not this is what you want depends on what you are planning to do with the modified values. You could always do:
foreach ( map { $_ +1 } @a ) { #whatever }
As well. HTH
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Modify array elements inside for loops
by merlyn (Sage) on Mar 06, 2001 at 21:40 UTC |