You see the code instead of the output of the program, because you did not configure the web server to run the program, so by default it serves to work with the file as text / regular.
How you configure it depends on the server software you are using. For example, see Apache 2.2 CGI docs .
Secondly, the shebang line is missing. The program should begin with:
/usr/bin/perl - Perl, .
, :
use strict; use warnings;. Perl, , .- HTML Doctype, quirks. Doctype boilderplate HTML, .