in reply to source code of cgi script directly opens in browser
i recommend that you read Chapter 12: Introduction to CGI (in PDF format) from the freely available book Beginning Perl.