in reply to pre-processing in CGI::Ajax?

Can I create a Javascript function which when executed calls a Perl routine on the server?

That's what AJAX is!