in reply to updating an array of strings
The right way to do this is simply to use 'foreach'. Eg to replace every occurence of 'cat' with 'dog':
foreach (@strings) { s/cat/dog/g; }
A common error is to use 'map':
map { s/cat/dog/g; } @strings;
The point of map is that it returns a copy of the transformed list. If you don't want a new list, but just want to transform the list 'in place', use foreach.
|
|---|