in reply to how to print CGI header

Looking through the CGI documentation, especially the section on Support for JavaScript, the following should do what you want:

my $js = 'alert("Hello World");'; # replace this with your JS code print start_html(-head=>[Link({-rel=>'StyleSheet', -href=>'main.css', +-type=>'text/css'}), script($js)], -title=>"Welcome to my site!", -me +ta=>{'robots' =>'nofollow'});

But you could also consider using one of the many templating systems instead of creating your HTML by writing code. HTML::Template is a very simple templating system, and Template Toolkit has much more options.

You should also be aware that disabling the right-click does not serve any purpose other than to annoy the visitors to your website - the context menu offers many options, like navigation, cut'n'paste or inspection of the website addresses. It's easy to disable any JavaScript code that tries to intercept right-clicks.