Home
Perl 5 Tutorial, First Edition

Perl 5 Tutorial
First Edition

 

Edition: First Edition
No. of Pages: 241
Language: English
Date of release: 31/12/2003

Release Notes | Table of Contents

Available Formats:
Mirror(s):
geek.scorpiorising.ca (United Kingdom)
www.sicomm.us (United States)
www.ghirai.com (United States)

My grateful thanks go to the owners of the aforementioned mirror(s) for their generosity in providing server resources to help distribute the document.

FUTURE DIRECTIONS

This tutorial is a long-term project and, as I mentioned in the preface, new materials will be constantly added to the tutorial to further the breadth as as well as depth of the coverage. While the First Edition has been officially released, the process of preparing the Second Edition of the tutorial has also been started. A plan for a drastic rewrite is afoot. More examples will also be added. The Second Edition shall comprise of two major parts covering the Perl fundamentals and more advanced topics, respectively.

In the First Edition, the manuscripts are directly typeset with LaTeX to generate the official PDF version. I expect the manuscripts for the Second Edition shall be rewritten in XML which will then be converted to LaTeX and HTML in order to generate an HTML version for viewing online.

ERRATA

Note: Page numbers listed below are as printed at the top of each page, NOT the one reported by your PDF viewer.

Page Section Context Error
32 3.2.6 Paragraph above Example 3.5 This is done on line 25.

TABLE OF CONTENTS

Preface
Chapter 1  Introduction to Programming
1.1  What is Perl?
1.2  A Trivial Introduction to Computer Programming
1.3  Scripts vs. Programs
1.4  An Overview of the Software Development Process

Chapter 2  Getting Started
2.1  What Can Perl Do?
2.2  Comparison with Other Programming Languages
2.2.1  C/C++
2.2.2  PHP
2.2.3  Java/JSP
2.2.4  ASP
2.3  What do I need to learn Perl?
2.4  Make Good Use of Online Resources
2.5  The Traditional "Hello World" Program
2.6  How A Perl Program Is Executed
2.7  Literals
2.7.1  Numbers
2.7.2  Strings
2.8  Introduction to Data Structures

Chapter 3  Manipulation of Data Structures
3.1  Scalar Variables
3.1.1  Assignment
3.1.2  Nomenclature
3.1.3  Variable Substitution
3.1.4  substr() --- Extraction of Substrings
3.1.5  length() --- Length of String
3.2  Lists and Arrays
3.2.1  Creating an Array
3.2.2  Adding Elements
3.2.3  Getting the Number of Elements in an Array
3.2.4  Accessing Elements in an Array
3.2.5  Removing Elements
3.2.6  splice(): the Versatile Function
3.2.7  Miscellaneous List-Related Functions
3.2.8  Check for Existence of Elements in an Array (Avoid!)
3.3  Hashes
3.3.1  Assignment
3.3.2  Accessing Elements in the Hash
3.3.3  Removing Elements from a Hash
3.3.4  Searching for an Element in a Hash
3.4  Contexts
3.5  Miscellaneous Issues with Lists

Chapter 4  Operators
4.1  Introduction
4.2  Description of some Operators
4.2.1  Arithmetic Operators
4.2.2  String Manipulation Operators
4.2.3  Comparison Operators
4.2.4  Equality Operators
4.2.5  Logical Operators
4.2.6  Bitwise Operators
4.2.7  Assignment Operators
4.2.8  Other Operators
4.3  Operator Precedence and Associativity
4.4  Constructing Your Own sort() Routine

Chapter 5  Conditionals, Loops & Subroutines
5.1  Breaking Up Your Code
5.1.1  Sourcing External Files with require()
5.2  Scope and Code Blocks
5.2.1  Introduction to Associations
5.2.2  Code Blocks
5.3  Subroutines
5.3.1  Creating and Using a Subroutine
5.3.2  Prototypes
5.3.3  Recursion
5.3.4  Creating Context-sensitive Subroutines
5.4  Packages
5.4.1  Declaring a Package
5.4.2  Package Variable Referencing
5.4.3  Package Variables and Symbol Tables
5.4.4  Package Constructors with BEGIN {}
5.5  Lexical Binding and Dynamic Binding
5.6  Conditionals
5.7  Loops
5.7.1  for loop
5.7.2  while loop
5.7.3  foreach loop
5.7.4  Loop Control Statements
5.8  Leftovers

Chapter 6  References
6.1  Introduction
6.2  Creating a Reference
6.3  Using References
6.4  Pass By Reference
6.5  How Everything Fits Together
6.6  Typeglobs

Chapter 7  Object-Oriented Programming
7.1  Introduction
7.2  Object-Oriented Concepts
7.2.1  Programming Paradigms
7.2.2  Basic Ideas
7.2.3  Fundamental Elements of Object-Oriented Programming
7.3  OOP Primer: Statistics
7.3.1  Creating and Using a Perl Class
7.3.2  How A Class is Instantiated
7.4  Inheritance

Chapter 8  Files and Filehandles
8.1  Introduction
8.2  Filehandles
8.2.1  open a File
8.2.2  Output Redirection
8.3  File Input and Output Functions
8.3.1  readline() --- Read a Line from Filehandle
8.3.2  binmode() --- Binary Mode Declaration
8.3.3  read() --- Read a Specified Number of Characters from Filehandle
8.3.4  print()/printf() --- Output to a Filehandle
8.3.5  seek() --- Set File Pointer Position
8.3.6  tell() --- Return File Pointer Position
8.3.7  close() --- Close an opened Filehandle
8.4  Directory Traversal Functions
8.4.1  opendir() --- Open a Directory
8.4.2  readdir() --- Read Directory Content
8.4.3  closedir() --- Close a Directory
8.4.4  opendir() --- Open a Directory
8.5  File Test Operators
8.6  File Locking

Chapter 9  Regular Expressions
9.1  Introduction
9.2  Building A Pattern
9.2.1  Getting Your Feet Wet
9.2.2  Introductions to m// and the Binding Operator
9.2.3  Metacharacters
9.2.4  Quantifiers
9.2.5  Character Classes
9.2.6  Backtracking
9.3  Regular Expression Operators
9.3.1  m// --- Pattern Matching
9.3.2  s/// --- Search and Replace
9.3.3  tr/// --- Global Character Transliteration
9.4  Constructing Complex Regular Expressions

Chapter 10  Runtime Evaluation & Error Trapping
10.1  Warnings and Exceptions
10.2  Error-Related Functions
10.3  eval
10.4  Backticks and system()
10.5  Why Runtime Evaluation Should Be Restricted
10.6  Next Generation Exception Handling
10.6.1  Basic Ideas
10.6.2  Throwing Different Kinds of Errors
10.6.3  Other Handlers
10.7  Other Methods to Catch Programming Errors
10.7.1  The -w Switch --- Enable Warnings
10.7.2  Banning Unsafe Constructs with strict
10.7.3  The -T Switch --- Enable Taint Checking

Chapter 11  CGI Programming
11.1  Introduction
11.2  Static Content and Dynamic Content
11.2.1  The Hypertext Markup Language
11.2.2  The World Wide Web
11.3  What is CGI?
11.4  Your First CGI Program
11.5  GET vs. POST
11.6  File Upload
11.7  Important HTTP Header Fields & Environment Variables
11.7.1  CGI-Related Environment Variables
11.7.2  HTTP Header Fields
11.8  Server Side Includes
11.9  Security Issues
11.9.1  Why Should I Care?
11.9.2  Some Forms of Attack Explained
11.9.3  Safe CGI Scripting Guidelines

Appendix A  How A Hash Works
A.1  Program Listing of Example Implementation
A.2  Overview
A.3  Principles
A.4  Notes on Implementation

Appendix B  Administration
B.1  CPAN
B.1.1  Accessing the Module Database on the Web
B.1.2  Package Managers
B.1.3  Installing Modules using CPAN.pm
B.1.4  Installing Modules --- The Traditional Way

Appendix C  Setting Up a Web Server
C.1  Apache
C.1.1  Microsoft Windows
C.1.2  Unix

Appendix D  A Unix Primer
D.1  Introduction
D.1.1  Why Should I Care About Unix?
D.1.2  What Is Unix?
D.1.3  The Overall Structure
D.2  Filesystems and Processes
D.2.1  Overview
D.2.2  Symbolic Links and Hard Links
D.2.3  Permission and Ownership
D.2.4  Processes
D.2.5  The Special Permission Bits

Appendix E  In the Next Edition

Last Updated on 31/01/2006
Chan Bernard Ki Hong (1999-2004).
Downloads | FAQ | Legal Information | Feedback | Validate This Page