Next:
Introduction to Perl
Up:
Practical Perl Programming
Previous:
Practical Perl Programming
Contents
Contents
Introduction to Perl
What is Perl?
Origins
Similar to C?
Cost and Licensing
Installing Perl Installed
Getting and Installing Perl
Writing Perl Programs
Creating the Program
Invocation
Comments in Your Program
Further Reading/Information
Numeric and String Literals
Numeric Literals
String Literals
Example: Double-Quoted Strings
Variables
Scalar Variables
Defining Scalar Variables
String Scalar Variables
Arrays
What is an Array?
Literal Arrays
Indexed Arrays
Some Useful Array Functions
Associative Arrays
Associative Array Operators
Operators
The Binary Arithmetic Operators
The Unary Arithmetic Operators
The Logical Operators
The Bitwise Operators
Comparison operators for numbers and strings
The Range Operator (..)
The String Operators (. and x)
Order of Precedence
Perl Statements
Understanding Expressions
Statement Blocks
Statement Blocks and Local Variables
If/Unless statement
The for statement
The while/until statement
The foreach statement
Functions
Using the Parameter Array (
@_
)
Passing Parameters by Reference
Scope of Variables
Using a List as a Function Parameter
Nesting Function Calls
Using a Private Function
String Functions
Array Functions
Summary
References
Reference Types
Passing Parameters to Functions
The ref() Function
Example: Creating a Data Record
Interpolating Functions Inside Double-Quoted Strings
Summary
Files -- Input and Output in Perl
Some Files Are Standard
Using the Diamond Operator (<>)
File Test Operators
File Functions
Reading Directories
Reading and Writing Files
Binary Files
Getting File Statistics
Printing Revisited
Regular Expressions
What are regular Expressions
Using Regular Expressions
Special pattern matching character operators
Backtracking
Setting the Target Operator (Binding)
Substitution
The Matching Operator (m//)
The Matching Options
The Translation Operator (tr///)
The Translation Options
The Binding Operators
Character Classes
Quantifiers
Pattern Memory
Pattern Precedence
Extension Syntax
Pattern Examples
Some Practical Examples
Using the Match Operator
Using the Substitution Operator
Example: Using the Translation Operator
Example: Using the
Split()
Function
Reports
Format Statements
Field Lines
Report Headings
Special Variables
What Are the Special Variables?
Example: Using the
DATA
File Handle
Example: Using the
%ENV
Variable
Handling Errors and Signals
Checking for Errors
Using
errno
Using the
||
Logical Operator
Using the
die()
Function
Using the
warn()
Function
Trapping Fatal Errors
Using the
eval()
Function
Signals
How to Handle a Signal
Objects in Perl
What are objects?
Classes
Abtraction
Polymorphism:Overriding Methods
Encapsulation:Keeping Code and Data Together
Objects in Perl
Bless the Hash and Pass the Reference
Initializing Properties
Using Named Parameters in Constructors
Inheritance: Perl Style
Polymorphism
One Class Can Contain Another
Static Versus Regular Methods and Variables
Perl Modules
Module Constructors and Destructors
The
BEGIN
Block
The
END
Block
Symbol Tables
The
require
Compiler Directive
The
use
Compiler Directive
Pragma in Perl
The
strict
Pragma
The Standard Modules
strict, my()
and Modules
Module Examples
The
Carp
Module
The
English
Module
The
Env
Module
Debugging Perl
Syntax Errors
Common Syntax Errors
Logic Errors
Using the
-w
Command-Line Option
Being Strict with Your Variables
Stepping Through Your Script
Displaying Information
Using Breakpoints
Creating Command Aliases
Using the Debugger as an Interactive Interpreter
Summary
Perl Command-Line Options
How Are the Options Specified?
The Command-line Options
Example uses of command-line options
Using the
-0
Option
Using the
-n
and
-p
Options
Using the
-i
Option
Using the
-s
Option
Summary
Networking with Perl
Sockets
Clients and Servers
The Server Side of a Conversation
The Client Side of a Conversation
Some Network Examples
Using the Time Service
Sending Mail (SMTP)
The
MAIL
Command
The
RCPT
Command
The
DATA
Command
Reporting Undeliverable Mail
Using Perl to Send Mail
Receiving Mail (POP)
Checking for Upness (Echo)
Transferring Files (FTP)
The World Wide Web (HTTP)
CGI Programming in Perl
CGI Scripting
What is a CGI Script?
Writing and Running CGI Scripts
Why Use Perl for CGI?
CGI Apps versus Java Applets
Should You Use CGI Modules?
How Does CGI Work?
Calling Your CGI Program
Beginning CGI Programming in Perl
CGI Script Output
A First Perl CGI Script
Exectiion of CGI Programs
Why Are File Permissions Important in UNIX?
HTTP Headers
CGI and Environment Variables
URL Encoding
Security
CGIwrap and Security
The Other Side of CGI:Input -- HTML Forms
A Brief Overview of HTML
Server-Side Includes
Forms: Facilitating User Input and Interaction
Forms and CGI: What are they?
Some Example Forms
The FORM Tag
Entering Data
The Submit Button
Text Input
Password
Associating labels with text and password input
Radio Buttons
Checkboxes
Assigning Initial Input Values to
Select
Textarea
Hidden Input
An Example Form
HTML Forms as an Interface to Databases
Further Information
CGI Script Input: Accepting Input To Perl Scripts
Accepting Input from the Browser
Passing Data to a CGI Script
A Simple Form CGI Script Call
The Other Side -- receiving and processing information in CGI ( Perl) script
cgi-lib.pl
The
cgi.pm
module
A Minimal Form Response CGI Perl Script
Multiple argument input to a Perl CGI script
Some Example Perl CGI Scripts
Red, Green and Blue to Hexadecimal Converter
An Address Book Search Engine
Creating a Guest Book
A Web Page Counter
Using Perl with Web Servers
Server Log Files
Reading a Log File In Perl
Listing Access by Document
Looking at the Status Code
Existing Log File Analyzing Programs
Creating Your Own CGI Log File
Internet Resources
Web Sites
Usenet Newsgroups
A Quick Quide to HTML
Basic HTML Programming
HTML
Hypertext Terminology
Creating HTML Documents
Learning HTML
Anatomy of Any HTML Document
HTML Tags
Basic HTML Page Structure
Summary of Basic HTML Tags
Bare-bones example of HTML
Basic HTML Coding
Head elements
The Body Element
Headings
Paragraphs
Comments
Links and Anchors
Linking to Other Documents
Relative, Absolute and remote Links
Anchors
Lists
Unordered or Bulleted lists
Ordered or Numbered lists
Glossary or Definition Lists
Nesting Lists
Preformatted Text
In-Line Images
External Images, Sounds, Video
Things to remember when HTML programming
Text Formatting with HTML
Logical Character Formatting
Physical Character formatting
Special Characters
Horizontal rules and Line breaks
Fonts and Font Sizes
Recommended Reading
dave@cs.cf.ac.uk