print "Content-type: text/html\n\n";
and not this:
print "Content-type: text/html\r\n\r\n";
The second format would work, but only if your script runs on
Unix. Because Perl both began on Unix and has become a cross-platform
language, printing "\n" in a script will always
output the operating system's default line ending.
There is a simple solution. CGI requires that the web server
translate your operating system's conventional line ending into
a CRLF for you. Thus for the sake of portability, it is always best
practice to print a simple line feed
("\n"): Perl will output the operating
system's default line ending, and the web server will
automatically convert this to the CRLF required by HTTP.