I started writing a longer tutorial, trying to introduce new users to Perl, but it was lost, so I'll just use the simplest CGI script possible to explain the basics of CGI with Perl for complete novices.
First you need to tell Perl where it is.
The default location as you can see is /usr/bin/perl
You can see the w tag after, which stands for warnings.
Everyone makes mistakes. That's why you need to make sure you have ways to debug your code and figure out what went wrong.
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #debugging line
That is what is called a module. What this line does is print warnings, and problems that cause the program to be unable to run.
This is the module that actually does all the work of printing webpages for you.
This calls the CGI module and I bet you can guess what it does.
That prints the HTML header.
print $cgi->start_html("Hello World");
This actually starts the HTML, and sets the title as Hello World
[code]
print "<h1>Hello World!</h1>";
Prints the header tag saying Hello to the world.
And finally, if you are too lazy to copy it line by line:
#!/usr/bin/perl -w
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #debugging line
use CGI; # CGI Module
$cgi = CGI->new; # Creates new CGI
print $cgi->header; # Prints HTML Header
print $cgi->start_html("Hello World"); # Starts HTML
print "<h1>Hello World!</h1>"; # HELLO WORLD!
print $cgi->end_html; # end HTML