in reply to replace character to bracket in perl

As GotToBTru says, the process for mapping your input string to your output string is not clear. See How do I post a question effectively?. Can you wrap your input and output strings in <code> tags and describe in English or pseudocode the steps to go from abcd| a a7- to [a] [a7] [a], or however that is supposed to be?

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.