Programming Perl 101

3 - Starting Off
The script we are about to create will take the information your user submits in a standard feedback form and then load a page showing him what he just entered. Not terribly useful, but a great example to get us started.

In this example, we'll have someone enter their name, city, and favorite food (after all, that's the basic vital information for all of us, right?).

First, we create the HTML page with the form:

<title>Submit Your Information</title>
<h1>Submit Your Information</h1>
<form action="display.cgi" method="post" >
First Name: <input type="text" size="30" name="first">
City: <input type="text" size="30" name="city">
Favorite Food: <input type="text" size="30" name="food">
<P><input type="submit" name="submit" value="Submit!">
<input type=reset name=reset value="Reset">

Do you see the names of those form fields? Those are the identifying values assigned to each form field the user will be entering his information into. In this case they are "first," "city," and "food." Think of the names given to form fields as containers that will hold the data entered by a user.

The way this works is that when a user enters their name into the appropriate form field, the name tag will "attach" itself to the data entered in order to identify it for later use. If a user were to enter the word "Marvin" into the "first" field, the word "Marvin" would be assigned the "first" tag. As you'll soon see, we can use Perl to display whatever text has been given the "first" tag. Starting to make some sense?

Now, as you'll notice, we have the form action set to "display.cgi." This line in the form tells us that this information (with name tags attached, of course) will be sent to a certain file. In this case, display.cgi. Since, display.cgi doesn't exist yet, let's create it!