in reply to Changing a bit in a string

Somehow it is not working properly.

In what way did it not work? What did you do to debug it?

Show your code!

And read How (Not) To Ask A Question.

(hints: vec and/or the bit shift and logical bit operators described in perlop might be useful).