in reply to Perl script shows source code

Your output needs to lead with:

Content-Type: text/html

followed by a blank line.

The truth is this is the most basic of issues in CGI development and is supplied in every article or book regarding the issue.