- You have been told on repeated occasions to use strict; and use warnings;. I won't review any code of yours longer than 5 lines that doesn't have those at the top.
- Start small - create a small script that uses a small template, without Javascript or Unicode. Learn the tool, then apply it. You're going backwards.
- If you have a problem, you should remove pieces from the problemspace until you have the smallest example that demonstrates the problem. If you remove a piece and the problem goes away, the problem is related to the piece you removed.
- Have you compared the HTML you generated with your old code against the HTML you're generating with the new code? Do you still have your old code? (You are using some sort of source control management like CVS or Subversion, right?)
- Have you tried to run this script from the command-line? CGI has a command-line mode that's kinda handy.
Start with that. If those steps don't fix the problem, come back and ask questions then.