Web Perl   «Prev  Next»

Lesson 13

Perl CGI http Conclusion

In this module you learned about CGI, how it works, and how to use it. You learned that CGI runs on the HTTP server, and you learned enough about HTTP to understand the overall strengths and weaknesses of the protocol.
You should also feel comfortable in your understanding of the details of CGI, its standard variables, and how to run a CGI program on your server, and you have actually written and run a CGI on your server. In the next module, important features of the Perl language that make Web programming easier will be discussed, such as:
  1. Using regular expressions
  2. Working with arrays and hashes
  3. Working with references
  4. Creating complex data structures in Perl

The world's web browsers, servers, and related web applications all talk to each other through HTTP, the Hypertext Transfer Protocol. HTTP is the common language of the modern global Internet.

File Types

Billions of JPEG images, HTML pages, text files and other file types are transported through the Internet each and every day. HTTP moves the bulk of this information quickly, conveniently, and reliably from web servers around the world to web browsers on people's desktops, laptops and mobile devices.
Because HTTP uses reliable data-transmission protocols, it guarantees that your data will not be damaged or scrambled in transit, even when it comes from the other side of the globe. This is good for you as a user, because you can access information without worrying about its integrity. Reliable transmission is also good for you as an web developer, because you do not have to worry about HTTP communications being destroyed, duplicated, or distorted in transit. You can focus on programming the distinguishing details of your application, without worrying about the flaws of the web.

Types of Web Servers

Web content is published on web servers, whether it is Apache, IIS, Nginx or Tomcat. Web servers speak the HTTP protocol, so they are often called HTTP servers. These HTTP servers store the Internet's data and provide the data when it is requested by HTTP clients. The clients send HTTP requests to servers, and servers return the requested data in HTTP responses, as described in Figure 1-13. HTTP clients and HTTP servers make up the basic components of the World Wide Web.

The client makes a request from server
The client makes a request from the server

The most common client is a web browser such as Opera, Firefox, Edge or Google Chrome. Web browsers request HTTP objects from servers and display the objects on your screen. When you browse to a page, such as "https://www.dispersednet.com" your browser sends an HTTP request to the server www.dispersednet.com (see Figure 1-13). The server tries to find the desired object and, if successful, sends the object to the client in an HTTP response, along with the type of the object, the length of the object, and other information.

Installing Third-Party Modules

For most modules (particularly those from CPAN), the installation process is fairly straightforward:
  1. Download the module, and extract it using tar and gunzip, for example:
    $ gunzip -c module.tar.gz | tar xf -
    
    This should create a new directory with the module contents.
  2. Change to the module directory.
  3. $ perl5 Makefile.PL
    This will check that the module contents are complete and that the necessary prerequisite modules are already installed. It will also create a makefile that will compile (if necessary) and install the module. As in the original installation process, a make test will verify that the compilation and configuration of the package works before you come to install it. You should report any problems to the package's author.
  4. To install the module, type
    $ make install

    This will copy the modules and any required support files into the appropriate directories. A better, and less interactive, solution is to use the CPAN module to do the downloading, building, and installation for you.

Ad Regular Expressions