#10 Hello World

This is the CGI version of "Hello World." In spite of it being a very simple program, it is extremely useful. Why? Because if you can run it, you know that your server is properly configured to run CGI programs. And from bitter experience I can tell you that sometimes configuring the server is half the battle.

The Code

  1 #!/usr/bin/perl -T
  2
  3 use strict;
  4 use warnings;
  5
  6 print <<EOF
  7 Content-type: text/html
  8
  9 <HEAD><TITLE>Hello</TITLE></HEAD>
 10 <BODY>
 11 <P>
 12 Hello World!
 13 </BODY>
 14
 15 EOF

Running the Script

To run the script, just point your web browser at the correct URL. If you are using the default Apache configuration, the script resides in ~apache/cgi-bin/hello.pl and the URL to run it is http://server/cgi-bin/hello.pl ...

Get Wicked Cool Perl Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.