in reply to call js function from CGI?

There is no such thing as a cgi page. Doh- you say.
The clarity of this concept is vital.
You have to separate the idea of the client and what it/they experiences (the audience computer/visitors) and what your application (cgi/server) is doing.
Part of the Javascript idea is that you potentially let the end user's machine do some of the work, flip little pictures, throw javascript alerts.. draw little smily faces all over some dom node.

Think of your cgi's output as if you had written it yourself by hand.
So, restate your question. The right question is- Is there a simple way to execute a javascript function within a html(xhtml/rss/flash/anything downloaded from your server) page?
This has nothing to do with perl, and everything to do with html/javascript, google for body onload/etc if you want this to happen automatically without user interaction.

That said, CGI has some shortcuts to the html you spit out, and some minor javascript support.

That said, my advice is- if you are coding server side, forget javascript. Serve static content in the most boring manner possible. If you use actual content in your website, users will come.
Let the web designers and worry about javascript.