Please refer to How I can execute Javascript into Perl? in PERL-CGI section.