in reply to how can i execute javascript in perl
If you want to run the JavaScript on the server then you could use something like JavaScript::SpiderMonkey.
If you want the Perl to just output an HTML document that includes some JavaScript for the browser to execute - then do that, it is just text wrapped with <script> and </script>.
In Section
Seekers of Perl Wisdom