in reply to Replace characters within string

Stuff like [I|O|P|B|M] doesn't do what you think it does. In character classes (the square brackets) the pipe character is a literal pipe character, not an operator. So you should write [IOPBM].

See "Special Characters Inside a Bracketed Character Class" in perlrecharclass for details.

Yet another proof that Guido was right.

Are these characters amino acids or something? It's a good thing that Perl is still used by geneticists, otherwise we would've already been exterminated by engineered diseases.