INT322
Monday, January 19, 2004
Objective
By the end of this week you will:
(1)understand the interaction between a browser, web server,
web script, interpreter, and database server.
(2) know what Perl is and why it is used on the web.
Today
Announcements From Last Week...
Browser Interactions Quiz
Announcements
See me for your account if you don’t have one yet.
Exercise 1 due Friday, January 23 Post a message on Blackboard Edit your Zenit homepage
Attending the other section of the course...
Web Sites: Reminder
Blackboard - Marks, Discussion http://my.senecacollege.ca/
INT322 Web Site
http://cs.senecac.on.ca/~int322/
Web Sites: Reminder
Instructor’s Home Page
http://cs.senecac.on.ca/~ctyler/
Instructor’s Zenit Home Page
http://zenit.senecac.on.ca/~tyler/
Building on Last Session...
bash script
interpreter
Pathnames
Review...
Absolute Relative
Relative-to-home
Namespace Mapping
Web pathnames vs. file pathnames Translation of namespaces
Not necessarily 1:1
Web Interactions - Static
Browser -> Apache
Apache <-> Filesystem
Apache -> Browser
Web Interactions - Static
Browser -> Apache http(+content)
Apache <-> Filesystem
Apache -> Browser http+content
Web Interactions - Dynamic
Browser -> Apache http(+content) Apache <-> Filesystem
Apache -> OS exec() CGI(+content) OS exec() -> Interpreter
Interpreter -> Script
Script -> Apache CGI+http+content Apache -> Browser http+content
Web Interactions - HTTP Header Format
HTTP Headers are based on ...
?
Web Interactions - HTTP Header Format
HTTP Headers are based on ...
RFC822 (E-mail)
Method/status Header1: value Header2: value blank line Body of message
Web Interactions - Request Headers (Browser)
GET / HTTP/1.1
Host: zenit.senecac.on.ca blank line
Web Interactions - Response Headers (Server)
HTTP/1.1 200 OK
Date: Mon, 09 Sep 2002 14:49:09 GMT Connection: close
Content-Length: 1761 Content-Type: text/html blank line <xml ...
MIME-Types
MIME
MIME stands for ...?
MIME-Types
MIME
Multimedia Intenet Mail Extensions Format of the content type header?
MIME-Types
MIME
Multimedia Intenet Mail Extensions Content-type: type/subtype
Common MIME-Types
Raw text:
Common MIME-Types
Raw text: text/plain xhtml:
Common MIME-Types
Raw text: text/plain xhtml: text/html PNG graphic:
Common MIME-Types
Raw text: text/plain xhtml: text/html
PNG graphic: image/png Ogg Vorbis song:
Common MIME-Types
Raw text: text/plain xhtml: text/html
PNG graphic: image/png Ogg Vorbis song: audio/ogg MPEG film:
Common MIME-Types
Raw text: text/plain xhtml: text/html
PNG graphic: image/png Ogg Vorbis song: audio/ogg MPEG film: video/mpeg
CGI
CGI Stands for?
CGI
Common Gateway Interface
CGI Defines... ?
CGI
Common Gateway Interface
Defines server <-> script interaction How many paths?
CGI
Common Gateway Interface
Defines server <-> script interaction 4 paths (2 each direction)
What are the paths?
CGI
Common Gateway Interface
Defines server <-> script interaction 4 paths (2 each direction)
stdin stdout stderr
environment variables
Stdin, Stdout, Stderr
Stdin
’post’ form element values from browser via Apache
Stdout
headers, content to browser via Apache
Stdin, Stdout, Stderr
Stderr
error message
to logfiles via Apache (usually)
Environment Variables client and server details query-string value from URI
Basic CGI Program Requirements
1. Must be executable by ?
Basic CGI Program Requirements
1. Must be executable by the web server.
2. Must output ?
Basic CGI Program Requirements
1. Must be executable by the web server.
2. Must output at least one header followed by a blank line (usually the Content-type header).
3. Must finish executing before ?
Basic CGI Program Requirements
1. Must be executable by the web server.
2. Must output at least one header followed by a blank line (usually the Content-type header).
3. Must finish executing before anything is sent.
A Word on Web Design & CGI
Many sites have good programming or good design.
The two are not mutually exclusive!
A Word on Web Design & CGI
A good E-Commerce site should have:
Consistent navigation
Feedback on WHERE you are Location in the process
Colour & graphical mode cues
Quiz!
What is Perl?
Perl is an acronym for "Practical Extraction and Report Language".
started out as a scripting language to supplement rn, the USENET reader
created by Larry Wall.
What is Perl?
Perl:
is an interpreted language
is optimized for string manipulation, I/O and system tasks.
has built-in functions for almost all Unix system commands.
Perl History: 1987
Larry Wall posted Perl 1.0 to the usenet group comp.sources.
Perl History: 1988
Perl 2.0 is released with more text processing enhancements.
The open source community works on creating many modular extensions.
Perl History: 1989
Perl 3.0 is released under the GNU General Public License.
Perl History: 1990
Tom Christiansen’s The Answer to All Man’s Problems is published.
Perl History: 1991
Programming Perl, by Larry Wall and Randal L. Schwartz, is published by O’Reilly & Associates (the Camel)
Perl 4.0 is released under the GPL and the new Perl Artistic License.
Perl History: 1992
MacPerl is released (non-Mac interface).
Perl History: 1993
Final version of Perl 4 released.
MacPerl 4.1.0 has true Mac interface.
Perl community picks up steam -- mailing lists.
Learning Perl by Randal L. Schwartz is published.
Perl History: 1994
Perl 5 is born.
Perl 5 was a major reorganization that fixed may of the language’s limitations.
Tim Bunce introduces DBI/DBD.
Perl History: 1995
First recorded Perl CGI script.
Work on CPAN begins in earnest.
Perl History: 1996
The Perl Institute (TPI), a not-for-profit perl advocacy organization, is created.
The Perl Journal publishes its first issue.
Perl History: 1997
The Perl Institute announces a web-accessible mirror of CPAN.
Perl History: 1998
Perl Mongers is incorporated as a not-for-profit in New York state.
CPAN grows to 100 mirror sites.
Perl History: 1999
ActiveState Tool Corp. announces a corporate support package for Perl called PerlDirect.
Perl’s usage in developing web applications grows.
Perl History: 2000
Perl 5.6 is released for Windows, Solaris and Linux with Unicode support.
Version number: <major>.<minor>.<path>
Work on Perl 6 begins.
Perl 6 is a major rewrite
Separates compiler from runtime (Parrot)
Perl History: 2001
Perl 5.6.1 is released.
Perl History: 2002
Perl 5.8 released with strong Unicode support.
Work on Perl 6 continues.
Why Perl for web development?
CGI (the Common Gateway Interface) and Perl.
Perl is rapidly developing.
Text processing strength good match for web.
Why Perl for web development?
Free language, many online resources.
Interpreted - fast debug cycle.
Why Perl for web development?
Integrates well with Internet protocols.
Extensible using modules.
Links
http://www.perl.org/
http://www.perl.com/
http://www.cpan.org/
http://www.opensource.org/licenses/
Demonstration...
Is Perl Installed?
Is Perl installed?
What is the path?
Needed for #!
What Version is Installed?
Current version is 5.6.1 -v argument reports version
-V gives installation details
Getting and Installing Perl: Availability
Available under GPL and/or Artistic License.
Standard in RedHat, Slackware and SuSE.
Downloadable as source & binary.
Common Download Sites
http://www.perl.com/
http://www.cpan.org/
Acquiring and installing Perl
Use vendor distribution first.
Otherwise use perl.com/cpan.org source or binaries.
Installing from Source
gunzip stable.tar.gz tar xvzf stable.tar
follow README and INSTALL files
Install from Source
./Configure make make test
make install (as root)
Installing from Binaries
RPMs:
rpm -i ActivePerl-5.6.1.631-i686-linux.rpm
Modules
A module is a collection of functions.
Several included in core distribution.
Modules
Three types:
Pragmatic
Library
Object
Installing Modules
Obtain from CPAN
gunzip yourmodule.tar.gz tar xvf yourmodule.tar perl Makefile.PL make
make test make install
Automated Install
perl -MCPAN -e shell
get make test install readme