Please use [code][/code]
tags around your code and data, to preserve formatting and to improve readability.
The devil is in the details, and those are not clear to me. Can you explain exactly
what you are trying to do, and give us some examples of exactly
the kind of output we have to parse? What are the "special characters" that are involved, and what constitutes a line/field break in the stream? What kind of things does the bash script need to do with the input it gets?
Bash variables can store any character except null (so it can be used as a field delimiter, but is otherwise mostly impossible to deal with). Other than that, it's really just a trick of parsing the input. Assuming the output of the perl script is piped directly into the bash script, then it's just a matter of setting up the read command properly.
As for the second question, I'm not sure I understand your description there either, or what the posted script has to do with it. Are the "options" part of the same perl data stream? If so, then they must be parsed out of it as they are received. If not, then you may be able to just directly hand them to it on the command line. Or perhaps a separate file descriptor or fifo could be used.
BTW, be aware that "#!/bin/sh
" runs scripts in posix-compliant mode, and most shell-specific features become either illegal or undefined. To get the full compliment of features, you have to specify the exact shell to use, "#!/bin/bash