1. "Hello World"' or "Try to get a
simple script running before you attack the difficult ones !"
Here is the unavoidable "Hello World" example, customized to be
used as CGI. To see it in action you can try it here "Hello
World" .
NB: There are a few more lines to the script than absolutely necessary but
since they represent good practice and you should get used to them, they appear
already here !
#!/usr/local/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $query = new CGI;
my $date = localtime();
print $query->header();
print "
<html>
<head>
<title>The Unavoidable Hello World Example ;-)</title>
</head>
<body bgcolor=\"\#fffcc9\">
<h1>The Unavoidable Hello World Example </h1>
<p> The date is $date </p>
<hr noshade=\"noshade\";>
</body>
</html>
";
|
A few remarks which might help you to get started:
- Test the script before you try to run it via the Web-server:
Windows: |
The script must have the correct exctension, e.g. '.pl' for Perl, 'vbs' for
Virtual Basic. |
UNIX: |

|
The executable specified in the first line "#!/usr/local/bin/perl"
is not necessarily in the same location on your test system
and on the Web-server.
|
|
The file has to be executable, e.g. chmod 755 HelloWorld.pl !
|
- Put the script in the 'cgi-bin' directory of your Web-site. Per default it
is automatically created/enabled when using Web
Registration mechanism.