There are numerous ways to achieve what you want. For the substitution itself, the only thing that might be slightly beyond a pure beginner's knowledge, the first idea that comes to mind is to use the substitution operator,
s///. You'll find detailed documentation on this in this chapter
Regexp Quote Like Operators of the
perlop document. Look in particular at the
s/PATTERN/REPLACEMENT/msixpodualgcer sub-chapter and at the
e option modifier.