in reply to using map and swap (aka substitute)
Since you are overwriting the original array with the results, the simplest solution is:
s/_string$// for @list;
Which mutates the array in-place, thus avoids constructing two lists (in and out of map) as well as 'curing' the perceived problem.
And if you wanted to create a new list from the modified values whilst retaining the original array unmodified, I'd probably do it this way also:
my @list = ...; my @newList = @list; s/_string$// for @newList;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using map and swap (aka substitute)
by jwkrahn (Abbot) on Jan 14, 2013 at 22:45 UTC |