This course is intended for the beginner who wants to enter the world of programming interactive applications for the World Wide Web and quickly develop his or her skills. CIS 41 (Introduction to Computers) and CIS 42 (Program Design) are prerequisites for this course. The skills taught in those classes provide the essential foundations for keeping up with the early weeks of this class. Familiarity with HTML (Hypertext Markup Language) is helpful but not required.
In this class you will not only learn how to create CGI applications yourself, but you will also gain an understanding of how web server software works, and the methods by which data is communicated across the World Wide Web.
While successful web programming requires some amount of technical skill, it is just as important to approach programming tasks with creative, problem solving ideas. This course is structured with an emphasis on providing the skills necessary to successfully take on the real-world programming challenges you will face after you leave the classroom.
Classes #6 through #9 cover the basics of how to create Perl/CGI programs that can process information that users submit from web forms. During class #9 there will be a two hour Midterm Exam.
Classes #10 through #14 focus on more advanced Perl/CGI topics: building web applications that involve multiple sequential user interactions, using "cookies", interacting with databases, sending email, and more. There will be a Final Exam at the designated time during final exam week.
The tests will not emphasize rote learning or memorization - there will be no Scan-Tron tests, and you will not be asked to recite definitions of obscure terms. In fact, you will be allowed to use your notes and books during the tests.
The exams will consist of real-world programming challenges. You will need to draw upon the skills you have learned in the class lectures and in your weekly lab assignments to solve these problems during the time available (1 hour for the Quiz, and 2 hours for the Midterm and Final). In fact, one question in each test will come directly from a weekly lab assignment.
The job of Web servers is to respond to requests from Web browsers. Web servers respond to these requests by sending HTML documents. A Web browser receives the document, saves it temporarily on your computer's hard drive, deciphers it, and then displays it to you in the browser window.
The document sent to the Web browser might be a "static" document. That is, a document that is always the same for anyone who requests it. These pages are usually created by a person, and must be manually edited in order to change their content. Other documents are "dynamic" - their contents can vary depending on the circumstances. A simple example is a web page that displays the current time whenever it is requested. These pages are often created "on-the-fly" by a program that's called by your web server. Using CGI is the most common method for creating web pages containing dynamically generated content.
The best way to begin answering this question is to provide an example of what goes on when someone uses a CGI application. Here's an example of someone making a purchase on-line:
So, when you write a CGI program, you're often creating the "glue" between the Web server and other applications that you want to make available for use on the Web.
Note that simpler CGI programs do not communicate with external applications. These CGI programs receive a request from a Web server and generate a response completely on their own. After we learn the basics of Perl, we'll start our CGI programming with these simpler types.
The first word represented in the acronym CGI is "Common" - which means it's supported by all web servers and browsers. The second word is "Gateway" - if you want an application such as a database to be available to your Web site visitors, CGI provides the gateway between the Web server and the database. The third word is "Interface" - which refers to specifics of how the gateway works.
CGI programming is different from other kinds of programming in three important ways:
This is different from "client-side" programming - typically done with JavaScript - which is run within a user's Web browser. Client-side programming allows for changes within a user's browser without a new call to the Web server. The numbers entered into the form could be added, and a total displayed, without having to get a new page from the Web server.
Client-side programming is useful for creating flashy looking Web pages and doing relatively simple data manipulations, but it does not allow you to interact with any resources outside of the Web browser. For example, a client-side JavaScript program cannot directly communicate with a database on the Web Server.
Perl was created by Larry Wall, who has a background in linguistics, so you may find it a bit easier to understand than some other programming languages. It was created before the advent of the World Wide Web, primarily to serve as a tool for Unix administration tasks. The features that make it good for Unix administration also happen to make it a good choice for CGI programming. It's name comes from "Practical Extraction and Report Language," which is a concise description of what it's good at: extracting data from various sources (e.g. text files, CGI submissions, databases), manipulating it in desired ways (e.g. decoding the HTTP-encoded data that comes from a Web server), and generating a report (e.g. an HTML formatted page containing the desired information).
Some other things to know about Perl:
perl -v
You should get a response containing information on the version of Perl installed on your computer. If you get anything else, let me know.
#!perl print "Hello World!\n";
Then save the file to the "temp" folder on the C drive, with the name "hello.pl". In Windows, it's important to save your Perl scripts with the extension ".pl" - that way Windows will know that it should treat the file as a Perl script. In Unix, the file extension does not matter.
The first line of the script is called the "shebang" line. It's used to invoke (call) the Perl interpreter on your computer. We'll talk about this more in a later class. The second line is a simple Perl statement that prints the message "Hello World!" followed by a linefeed (that's what the "\n" does). The semicolon at the end indicates that this is the end of the statement.
Now go to your MS-DOS Window and move to the C:\temp directory. Then type:
hello.pl
You should get the message "Hello World!" as a response. If you don't, let me know. Note that the above only works on Windows NT. If you did this on Windows 95/98 or Unix, you'd type:
perl hello.pl