Can you show us the code you think has the problem? I mean the perl code that prints the <body ... bits. I suspect it's the variable interpolation problem again with single and double quotes for your print statement.
And please add some <code> ... </code> tags around your code.