in reply to Perl not running Javascript

Others have pointed out that the problem was invalid HTML.

To detect such glitches, you can always validate your HTML output.

Another possibility is to produce xhtml and send a proper header, so that browsers display the page in "standards compliance mode" and complains about invalid xhtml. At least Firefox does.