I am trying to implement substitution in perl.
I have a binary matrix and I would like to replace
0 with 1
and
1 with 2.
So i used the following line
s/1/2/g foreach @remaining;
However, this command ends up replacing my column names as well which has numbers in it. it converts, for example, 1234 to 2234.
I want it to match and replace only 1s and not 1234.
Use word boundaries like:
To replace 0 and 1 at the same time: