1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

17
1 Copyright © 2002 Pearson Education, Inc.

Transcript of 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

Page 1: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

1 Copyright © 2002 Pearson Education, Inc.

Page 2: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

2 Copyright © 2002 Pearson Education, Inc.

Chapter 1

Introduction to Perl and CGI

Page 3: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

3 Copyright © 2002 Pearson Education, Inc.

World Wide Web Background

The World Wide Web (WWW) is a collection of millions of documents and files that are accessible via the Internet

Web browsers are special computer programs that know how to retrieve and display files from the World Wide Web. Can work with • Play a file in the wav format (a sound file)• Interpret and then display a file in a gif format ( a digital picture

file) • Interpret and then display a file in the HTML format (a text-based

Web page)

Page 4: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

4 Copyright © 2002 Pearson Education, Inc.

Accessing HTML Files Over the Internet

Your PC(Internet connected)

Web Server(Internet connected)

URL:www.myserver.com/funstuff.html

Web browser

Find Web server at www.myserver.comWeb server receives

request

Sends file withfunstuff.html

The file funstuff.htmlHere are some fun thingsto do:

1. Play baseball.2. Go swimming.3. Go to a concert.

Web browser

Page 5: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

5 Copyright © 2002 Pearson Education, Inc.

HTML?

The Hypertext Markup Language (HTML) uses coded commands called HTML tags that provide instructions to Web browsers indicating how to display each page

Page 6: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

6 Copyright © 2002 Pearson Education, Inc.

Displaying HTML

Page 7: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

7 Copyright © 2002 Pearson Education, Inc.

Web Application Program

Carries out many dynamic tasks, such as the following: » Input a search term, search the WWW, and

return the results» Calculate and display the number of times that a

page has been viewed» Verify the input fields on a Web form» Save a Web form into a database» Display a special graph, or return the results of a

calculation based on data input from a form

Page 8: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

8 Copyright © 2002 Pearson Education, Inc.

The Common Gateway Interface

a standard that enables Web browsers to exchange data with computer programs located on a Web server

first appeared in the NCSA HTTPD Web server software built by the National Center for Super-computing Applications (NCSA). » one of the first widely used Web servers » was simple and the program source code was made

available for free It is simple to use and available on a variety of Web

servers.

Page 9: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

9 Copyright © 2002 Pearson Education, Inc.

How Browsers and Web Applications Work with

CGI

Web Server receives therequest and starts up te

CGI program.

Send results back

Please Enter APhone Number

Submit Erase

Web Browser

CGI-basedcomputerprogram

Web Browser

Phone QueryResults:

That isJohn Doe'sPhone Number

Web Browser

Your PC(Internet connected)

WebServer(Internet connected)

Page 10: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

10 Copyright © 2002 Pearson Education, Inc.

An Interface with Different Programming

Languages

Web application programs that are developed specifically to work with the CGI standard are known as CGI programs.

Lots of different programming languages can be used. For example, » Perl,» Visual Basic, » Java, » C,» C++,» and UNIX shell scripts.

Page 11: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

11 Copyright © 2002 Pearson Education, Inc.

The Perl Programming Language

Practical Extension and Reporting Language» invented in 1987 by Larry Wall at NASA’s Jet

Propulsion Laboratory» developed as a utility programming language for

the UNIX operating system » gained popularity because of its ease of use,

free availability via the Internet, and its powerful combination of

Page 12: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

12 Copyright © 2002 Pearson Education, Inc.

Why Perl is Popular

Perl is a free language with lots of free applications

Perl is easier to work with than many other languages

Perl provides a CGI interface module Perl applications are portable.

Page 13: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

13 Copyright © 2002 Pearson Education, Inc.

Why Perl is Popular

Perl is a free language with lots of free applications

Perl is easier to work with than many other languages

Perl provides a CGI interface module Perl applications are portable.

Page 14: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

14 Copyright © 2002 Pearson Education, Inc.

Internet Service Provider Issues

Some things to determine with your ISP» Allow CGI programs to execute on its Web-

server? Does it have Perl? What Version?» Login and initial password on the Web server?» Where do you put your Perl programs on the Web

server and what permission settings? » How much disk space for publishing?» Support FTP and/or Telnet access?

Page 15: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

15 Copyright © 2002 Pearson Education, Inc.

FTP Vs Telnet Access

PCWeb Server

Data

FTP copies data between computers.

Telnet allows you to connect, log in and executecommands on the server

FTP Session

Telnet Session

Page 16: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

16 Copyright © 2002 Pearson Education, Inc.

Summary

Web pages written in HTML are static and cannot interact with users.

CGI is an interface standard that allows computer programs to communicate with Web servers. Several programming languages can be used with CGI.

Page 17: 1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.

17 Copyright © 2002 Pearson Education, Inc.

Summary - II

Perl is a popular computer language that can be used for developing CGI programs.

You can install Perl and your own Web server software on your PC or workstation.

If you use an ISP’s Web server, find out several things about its services.