Quick Start Guide for Beginners to Perl / CGI

Get Help With All Aspects of Web Design & Design Software

Moderators: Moderator, Global Moderator

Post Reply
Endo
Hero Member
Hero Member
Posts: 1158
Joined: Wed May 05, 2004 9:05 am

Quick Start Guide for Beginners to Perl / CGI

Post by Endo »

[b]What is Perl?[/b]
Perl is a program that works behind HTML, and enables your web site to work with a more dynamic feel. For an example let’s use the Novice Forms script. You would setup an HTML form page setting all the variables, this is all done in HTML, no Perl would be on this page. Then the form contains a html \"POST\" statement, that posts to the Novice Forms Perl script. Then the Perl script process’s the information and sends you back to a success HTML page.
Here is a quick tutorial for individuals that are new to CGI and Perl.
Note: ALL example Perl Code is colored red.

This tutorial is written in English that you can understand, and less technical Jargon you can\'t.

Firstly all Perl scripts need to start with the path to Perl which is usually:
#!/usr/bin/perl
The path to Perl always needs to be alone on the very first line of each Perl Script with no spaces or characters before the pound sign. Basically this is where your script will find Perl on your server. Check with your host or systems administrator if you are unsure as to what the path is.

Code in perl is commented with a #Commenting is used to make notes in scripts, so if you want to go back and edit a script you created a year ago, you will know what you where trying to accomplish. All commented parts of your script will not show up on your page, or run through the script. When you stop commenting you must hit the enter key and start a new line to start re-coding Perl.

Example:
# THE BELOW VARIABLE IS SET TO VALUE \"will run\" - #
#(THIS LINE AND THE ABOVE TWO LINES ARE COMMENTED #
#AND WILL NOT SHOW UP OR RUN) #
$variable = \"will run\";

The escape character in Perl is a \
This is used to escape characters that declare variables and arrays. In actual Perl code if you need to use the \ as a regular character and not as code use: \\
The Escape character \ will be explained more in depth below........

[url=\"http://www.noviceforms.com/beginners.phtml\"][Continued.. | Source][/url]
[align=center]

Image

[color=\"#333333\"]Last Blog:[/color][color=\"Green\"] SUMMER [/color][color=\"black\"](30/11/06)[/color]

[/align]
Post Reply

Return to “Web Design Principles”