in reply to Weird substitution, missing output

Hello

Please show us the expected output and what you got for a short example input.

See also SSCCE

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Update

After reading brainfuck I'm understanding your problem is that you are inserting + symbols as c-code which is replaced later as BF code.

Translating linear code with a series of global s///g substitutions rarely works, because you are running over your own output.

But Anonymous Monk has already given you an excellent answer in the meantime.