• Introduction
    • Who Should Use This Book?
    • What do I Need?
    • How to Use This Book
    • Code Listings
    • Conventions
    • Overview
  • 01 - Getting Your Feet Wet
    • Origins
    • Similar to C?
    • Cost and Licensing
    • Do You Have Perl Installed?
    • Getting and Installing Perl
    • Your First Perl Program
      • Creating the Program
      • Invocation
    • Comments in Your Program
    • Summary
    • Review Questions
    • Review Exercises
  • 02 - Numeric and String Literals
    • Numeric Literals
      • Example: Numbers
    • String Literals
      • Example: Single-quoted Strings
      • Example: Double-Quoted Strings
      • Example: Back-Quoted Strings
    • Array Literals
      • Example: Printing an Array
      • Example: Nesting Arrays
      • Example: Using a Range of Values
    • Summary
    • Review Questions
    • Review Exercises
  • 03 - Variables
    • Scalar Variables
      • Example: Assigning Values to Scalar Variables
      • Changing Values in Scalar Variables
    • Array Variables
      • Example: Assigning Values to Array Variables
      • Example: Using Array Elements
      • Example: Using Negative Subscripts
      • Example: Determining the Number of Elements in an Array
      • Example: How to Grab a Slice (or Part) of An Array
    • Associative Array Variables
      • Example: Assigning Values to Associative Array Variables
    • Double Quoted Strings Revisited
      • Example: Variable Interpolation
      • Example: Using the $" Special Variable
    • Summary
    • Review Questions
    • Review Exercises
  • 04 - Operators
    • Operator Types
    • The Binary Arithmetic Operators
      • Example: The Exponentiation Operator
      • Example: The Modulus Operator
    • The Unary Arithmetic Operators
      • Example: The Pre-increment Operator
      • Example: The Pre-Decrement Operator
      • Example: The Post-increment Operator
    • The Logical Operators
      • Example: The "AND" Operator (&&)
      • Example: The "OR" Operator (||)
      • Example: The "NOT" Operator (!)
    • The Bitwise Operators
      • Example: Using the &, |, and ^ Operators
      • Example: Using the >> and << Operators
    • The Numeric Relational Operators
      • Example: Using the <=> Operator
    • The String Relational Operators
      • Example: Using the cmp Operator
    • The Ternary Operator
      • Example: Using the Ternary Operator to Assign Values
    • The Range Operator (..)
      • Example: Using the Range Operator
    • The String Operators (. and x)
      • Example: Using the Concatenation Operator
      • Example: Using the Repetition Operator
    • The Assignment Operators
      • Example: Assignment Using Array Slices
      • Example: Assigning an Array to Scalar Variables
    • Order of Precedence
      • Example: Order of Precedence
    • Summary
    • Review Questions
    • Review Exercises
  • 05 - Functions
    • Example: Using the Parameter Array (@_)
    • Example: Passing Parameters by Reference
    • Example: Scope of Variables
    • Example: Using a List as a Function Parameter
    • Example: Nesting Function Calls
      • Example: Using a Private Function
    • String Functions
      • Example: Changing a String's Value
      • Example: Searching a String
    • Array Functions
      • Example: Printing an Associative Array
      • Example: Checking the Existence of an Element
    • Summary
    • Review Questions
    • Review Exercises
  • 06 - Statements
    • Understanding Expressions
    • Statement Blocks
    • Statement Blocks and Local Variables
    • Statement Types
      • Example: Using the if Modifier
      • Example: Using the until Modifier
      • Example: Using the while Modifier
    • Summary
    • Review Questions
    • Review Exercises
  • 07 - Control Statements
    • Decision Statements
      • Example: The If Statement
    • Loop Statements
      • Example: While Loops
      • Example: Until Loops
      • Example: For Loops
      • Example: Foreach Loops
    • Jump Keywords
      • Example: The last Keyword
      • Example: The next Keyword
      • Example: The redo Keyword
      • Example: The goto Keyword
    • Summary
    • Review Questions
    • Review Exercises
  • 08 - References
    • Reference Types
      • Example: Passing Parameters to Functions
      • Example: The ref() Function
      • Example: Creating a Data Record
      • Example: Interpolating Functions inside Double-Quoted Strings
    • Summary
    • Review Questions
    • Review Exercises
  • 09 - Using Files
    • Some Files Are Standard
      • Example: Using STDIN
      • Example: Using Redirection to Change STDIN and STDOUT
      • Example: Using the Diamond Operator (<>)
    • File Test Operators
      • Example: Using File Tests
    • File Functions
      • Example: Opening Files
      • Example: Binary Files
      • Example: Getting File Statistics
      • Example: Using the Directory Functions
      • Example: Printing Revisited
    • Globbing
      • Example: Assigning a glob to an Array
    • Using Data Structures With Files
      • Example: Splitting a Record into Fields
    • Summary
    • Review Questions
    • Review Exercises
  • 10 - Regular Expressions
    • Pattern Delimiters
    • The Matching Operator (m//)
      • The Matching Options
    • The Substitution Operator (s///)
      • The Substitution Options
    • The Translation Operator (tr///)
      • The Translation Options
    • The Binding Operators (=~ and !~)
    • How to Create Patterns
      • Example: Character Classes
      • Example: Quantifiers
      • Example: Pattern Memory
      • Example: Pattern Precedence
      • Example: Extension Syntax
    • Pattern Examples
      • Example: Using the Match Operator
      • Example: Using the Substitution Operator
      • Example: Using the Translation Operator
      • Example: Using the Split() Function
    • Summary
    • Review Questions
    • Review Exercises
  • 11 - Creating Reports
    • What's a Format Statement?
      • Example: Using Field Lines
      • Example: Report Headings
      • Example: Using Functions in the Value Line
      • Example: Changing Formats
      • Example: Using Long Pieces of Text in Reports
      • Example: Writing to a File Instead of STDOUT
    • Summary
    • Review Questions
    • Review Exercises
  • 12 - Using Special Variables
    • What Are the Special Variables?
      • Example: Using the DATA File Handle
      • Example: Using the %ENV Variable
    • Summary
    • Review Questions
    • Review Exercises
  • 13 - Handling Errors and Signals
    • Checking for Errors
    • Example: Using the errno Variable
      • Example: Using the or Logical Operator
      • Example: Using the die() Function
      • Example: Using the warn() Function
    • Trapping Fatal Errors
      • Example: Using the eval() Function
    • What Is a Signal?
      • Example: How to Handle a Signal
    • Summary
    • Review Questions
    • Review Exercises
  • 14 - What Are Objects?
    • Learning about Classes
    • Abstract Thinking
    • Overriding Methods with Polymorphism
    • Keeping Code and Data Together with Encapsulation
    • How Perl Handles Objects
      • Example: Bless the Hash and Pass the Reference
      • Example: Initializing Properties
      • Example: Using Named Parameters in Constructors
      • Example: Inheritance, Perl Style
      • Example: Polymorphism
      • Example: How One Class Can Contain Another
    • Static Versus Regular Methods and Variables
    • Summary
    • Review Questions
    • Review Exercises
  • 15 - Perl Modules
    • Module Constructors and Destructors
      • The BEGIN Block
      • The END Block
    • Symbol Tables
    • The require Compiler Directive
    • The use Compiler Directive
    • What's a Pragma?
    • The strict Pragma
    • The Standard Modules
    • strict, my() and Modules
    • Module Examples
      • Example: The Carp Module
      • Example: The English Module
      • Example: The Env Module
    • Summary
    • Review Questions
    • Review Exercises
  • 16 - Debugging Perl
    • Syntax Errors
    • Common Syntax Errors
    • Logic Errors
      • Using the -w Command-line Option
      • Being Strict with Your Variables
      • Stepping Through Your Script
      • Examples: Displaying Information
      • Examples: Using the n Command
      • Examples: Using Breakpoints
      • Examples: Creating Command Aliases
      • Examples: Using the Debugger as an Interactive Interpreter
    • Summary
    • Review Questions
    • Review Exercises
  • 17 - Command-line Options
    • How Are the Options Specified?
    • What Are the Options?
      • Example: Using the -0 Option
      • Example: Using the -n and -p Options
      • Example: Using the -i Option
      • Examples: Using the -s Option
    • Summary
  • 18 - Using Internet Protocols
    • Sockets
      • The Server Side of a Conversation
      • The Client Side of a Conversation
    • 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)
    • Reading the News (NNTP)
    • The World Wide Web (HTTP)
    • Summary
    • Review Questions
    • Review Exercises
  • 19 - What is CGI?
    • Why use Perl for CGI?
    • CGI Apps vs Java Applets
    • Should You Use CGI Modules?
    • How does CGI Work?
    • Calling Your CGI Program
    • Your First CGI Program
    • Why Are File Permissions Important in UNIX?
    • HTTP Headers
    • CGI and Environment Variables
    • URL Encoding
    • Security
    • CGIwrap and Security
    • Cookies
      • Cookie Security
      • How Are Cookies Created And Read?
      • Can a Visitor's Browser Support Cookies?
    • Debugging CGI Programs
      • Sending Output to the Server's Log File
      • Sending STDERR to the Web Browser
      • CGITap
      • Generating an Error HTML Page
    • Summary
    • Review Questions
    • Review Exercises
  • 20 - Form Processing
    • A Brief Overview of HTML
    • Server-Side Includes
    • HTML Forms
    • Handling Form Information
    • Filling in a Form and Mailing the Information
    • Debugging Form Processing CGI Scripts
    • Creating a Guest Book for Your Site
      • The Basic Guest Book
    • Summary
    • Review Questions
    • Review Exercises
  • 21 - Using Perl with Web Servers
    • Server Log Files
      • Example: Reading a Log File
      • Example: Listing Access by Document
      • Example: Looking at the Status Code
      • Example: Converting the Report to a Web Page
      • Existing Log File Analyzing Programs
      • Creating Your Own CGI Log File
    • Communicating with Users
      • Example: Generating a What's New Page
      • Example: Getting User Feedback
    • Summary
    • Review Questions
    • Review Exercises
  • 22 - Internet Resources
    • Usenet Newsgroups
    • Web Sites
      • The Perl Language Home Page
      • Pearls of Wisdom by Larry Wall
      • Yahoo
      • The CGI.pm Module
      • Selina Sol's CGI Script Archive
      • The Web Developer's Virtual Library
      • Introduction to CGI
      • Perl for Win32
      • Randal L. Schwartz's Home Page
      • Dale Bewley's Perl Scripts and Links!
      • Matt's Script Archive
      • The Comprehensive Perl Archive Network
      • Database API for Perl
      • The cgi-lib.pl Home Page
      • The CGI Collection
      • HTML Form Processing Modules (HFPM) Home Page
      • PureAmiga
      • MacPerl
      • CGI Scripts and HTML Forms
      • The CGI Documentation by NCSA
      • Miscellaneous Sites
    • Internet Relay Chat, or IRC
    • Summary
  • Appendix A - Review Questions
    • Chapter 1
    • Chapter 2
    • Chapter 3
    • Chapter 4
    • Chapter 5
    • Chapter 6
    • Chapter 7
    • Chapter 8
    • Chapter 9
    • Chapter 10
    • Chapter 11
    • Chapter 12
    • Chapter 13
    • Chapter 14
    • Chapter 15
    • Chapter 16
    • Chapter 17
    • Chapter 18
    • Chapter 19
    • Chapter 20
    • Chapter 21
  • XB - Glossary
    • Abstraction
    • Alternation
    • Alternative Quotes
    • Anchor
    • Anonymous Functions and Variables
    • ANSI
    • Argument
    • Array
    • Array Context
    • Array Range
    • Array Slice
    • Array Splice
    • ASCII
    • Assignment
    • Associative Array
    • Associativity(left-to-right & right-to-left)
    • awk
    • Backtracking
    • Binary Mode
    • Bitwise Operations
    • Block
    • Call by Reference
    • Call by Value
    • Character Classes
    • Child Process
    • Class
    • Client/Server
    • Command-line Options
    • Compiler
    • Compile-time Error
    • Concatenation
    • Constant
    • Constructor
    • Context(Array & Scalar)
    • Control Characters
    • CR
    • Database
    • Data Type
    • Debugger
    • Declaration
    • Deconstructor
    • Defined
    • Delimiter
    • Dereference
    • Detail Line
    • Diamond Operator
    • Directory
    • Dotted Decimal Address
    • Empty Strings, Arrays, Lists, and Hashes
    • Encapsulation
    • Encryption
    • Endless Loop
    • Environment Variables
    • EOF
    • Escape Sequence
    • Expression
    • FF
    • Field
    • Filehandle
    • Footer
    • Formats
    • ftp
    • Function
    • Globbing
    • Greedy Regular Expressions
    • Grep
    • Hash
    • Header
    • Here Documents
    • Hexadecimal
    • Infinite Loop
    • Inheritance
    • Initialization
    • Interpolation
    • Interpreter
    • Inter-process Communication
    • I/O
    • IPC
    • Key-value Pair
    • Label
    • LF
    • Library
    • List
    • Literal
    • Loop
    • Meta Characters
    • Module
    • Namespace
    • Object
    • Octal
    • Operator
    • Parameter
    • Polymorphism
    • Port
    • Precedence
    • Procedure
    • Protocol
    • Range
    • Record
    • Reference
    • Regular Expression
    • Return Value
    • Run-time Error
    • Scalar
    • Scalar Context
    • Scope
    • Short-circuit Operators
    • Signals
    • Slice
    • Socket
    • Splice
    • Stack
    • Statement
    • STDERR, STDIN, and STDOUT
    • Subroutine
    • Text Mode
    • Undefined Value
    • Variable
    • Whitespace
  • XC - Function List
    • Functions by Category
    • Functions by Name
      • abs( [EXPR] )
      • accept ( NEWSOCKET, GENERICSOCKET )
      • alarm ( NUM_OF_SECONDS )
      • atan2 ( [EXPR] )
      • bind ( SOCKET, NAME )
      • binmode ( FILEHANDLE )
      • bless (REFERENCE, [CLASSNAME] )
      • caller ( [EXPR] )
      • chdir ( [DIRNAME] )
      • chmod (MODE, LIST )
      • chomp ( [STRING | LIST] )
      • chop ( [STRING | LIST] )
      • chown ( NUMERICAL_UID, NUMERICAL_GID, LIST )
      • chr ( NUMBER )
      • chroot ( DIR_NAME )
      • close ( FILEHANDLE )
      • closedir ( DIRHANDLE )
      • connect ( SOCKET, NAME )
      • cos ( [EXPR] )
      • crypt ( TEXT, SALT )
      • dbmclose ( HASH )
      • dbmopen ( HASH, DATABASE_NAME, MODE )
      • defined ( EXPR )
      • delete ( EXPR )
      • die ( [LIST] )
      • do ( SCRIPTNAME )
      • dump ( [LABEL] )
      • each ( HASH )
      • endgrent ( )
      • endhostent ( )
      • endnetent ( )
      • endprotoent ( )
      • endpwent ( )
      • endservent ( )
      • eof ( [FILEHANDLE] )
      • eval ( [EXPR | BLOCK] )
      • exec ( LIST )
      • exists ( EXPR )
      • exit ( [EXPR] )
      • exp ( [EXPR] )
      • fcntl ( FILEHANDLE, FUNCTION, PACKED_FLAGS )
      • fileno ( FILEHANDLE )
      • flock ( FILEHANDLE, OPERATION_FLAGS )
      • fork ( )
      • formline ( PICTURE, LIST )
      • getc ( [FILEHANDLE] )
      • getgrent ( )
      • getgrgid ( GID )
      • getgrname ( NAME )
      • gethostbyaddr ( ADDRESS, AF_INIT )
      • gethostbyname ( NAME, [PROTOCOL] )
      • gethostent ( )
      • getlogin ( )
      • getnetbyaddr ( ADDRESS, ADDR_TYPE )
      • getnetbyname ( NAME )
      • getnetent ( )
      • getpeername ( SOCKET )
      • getpgrp ( PID )
      • getppid ( )
      • getpriority ( WHICH, WHO )
      • getprotobyname ( NAME )
      • getprotobynumber ( NUMBER )
      • getprotoent ( )
      • getpwent ( )
      • getpwnam ( NAME )
      • getpwuid ( UID )
      • getservbyname ( NAME, PROTOCOL )
      • getservbyport ( PORT_NUMBER, PROTOCOL )
      • getservent ( )
      • getsockname ( SOCKET)
      • getsockopt ( SOCKET, LEVEL, OPTNAME )
      • glob ( EXPR )
      • gmtime ( [EXPR] )
      • grep ( BLOCK | EXPR, LIST )
      • hex ( EXPR )
      • import ( )
      • index ( STRING, SUBSTRING, [POSITION] )
      • int ( [EXPR] )
      • ioctl ( FILEHANDLE, FUNCTION, SCALAR )
      • join ( EXPR, LIST )
      • keys ( HASH )
      • kill ( SIGNAL, LIST )
      • lc ( EXPR )
      • lcfirst ( EXPR )
      • length ( [EXPR] )
      • link ( OLD_FILE, NEW_FILE )
      • listen ( SOCKET, QUEUESIZE )
      • local ( LIST )
      • localtime ( [EXPR] )
      • log ( [EXPR] )
      • lstat ( FILEHANDLE | EXPR )
      • map ( BLOCK | EXPR, LIST )
      • mkdir ( FILENAME, [MODE] )
      • msgctl ( ID, COMMAND, ARG )
      • msgget ( KEY, FLAGS )
      • msgrcv ( QUEUE_ID, BUFFER, BUFFER_SIZE, TYPE, FLAGS )
      • msgsnd ( QUEUE_ID, BUFFER, FLAGS )
      • my ( LIST )
      • oct ( [EXPR] )
      • open ( FILEHANDLE | EXPR | FILENAME )
      • opendir ( DIRHANDLE, EXPR | DIRNAME )
      • ord ( [EXPR] )
      • pack ( TEMPLATE, LIST )
      • pipe ( READHANDLE, WRITEHANDLE )
      • pop ( ARRAY_VARIABLE )
      • pos ( [SCALAR] )
      • print [FILEHANDLE] ( [LIST] )
      • printf [FILEHANDLE] ( FORMAT, LIST )
      • push ( ARRAY, LIST )
      • q ( LIST )
      • qq ( LIST )
      • quotemeta ( EXPR )
      • qw ( LIST )
      • qx ( LIST )
      • rand ( [EXPR] )
      • read ( FILEHANDLE, BUFFER, LENGTH, [OFFSET] )
      • readdir ( DIRHANDLE )
      • readlink ( [EXPR] )
      • recv ( SOCKET, BUFFER, LENGTH, FLAGS )
      • ref ( EXPR )
      • rename ( OLDNAME, NEWNAME )
      • reset ( [EXPR] )
      • reverse ( LIST )
      • rewinddir ( DIRHANDLE )
      • rindex ( STRING, SUBSTRING, [POSITION] )
      • rmdir ( [DIRNAME] )
      • scalar ( EXPR )
      • seek ( FILEHANDLE, POSITION, WHENCE )
      • seekdir ( DIRHANDLE, POS )
      • select ( [FILEHANDLE] )
      • select ( RBITS, WBITS, EBITS, TIMEOUT )
      • semctl ( ID, SEMNUM, CMD, ARG )
      • semget ( KEY, NSEMS, FLAGS )
      • semop ( KEY, OPSTRING )
      • send ( SOCKET, BUFFER, FLAGS, [TO] )
      • setgrent ( )
      • sethostent ( STAYOPEN )
      • setnetent ( STAYOPEN )
      • setpgrp (PID, PGRP)
      • setpriority ( WHICH, WHO, PRIORITY )
      • setprotoent ( STAYOPEN )
      • setpwent
      • setservent ( STAYOPEN )
      • setsockopt ( SOCKET, LEVEL, OPTNAME, OPTVAL )
      • shift ( [ARRAY] )
      • shmctl ( ID, CMD, ARG )
      • shmget ( KEY, SIZE, FLAGS )
      • shmread ( ID, BUFFER, POS, SIZE )
      • shmwrite ( ID, BUFFER, POS, SIZE )
      • shutdown ( SOCKET, HOW )
      • sin ( [EXPR] )
      • sleep ( [NUM_SECONDS_TO_SLEEP] )
      • socket ( SOCKET, DOMAIN, TYPE, PROTOCOL )
      • socketpair ( SOCKET1, SOCKET2, DOMAIN, TYPE, PROTOCOL )
      • sort ( [SUBNAME | BLOCK], LIST )
      • splice ( ARRAY, OFFSET, [LENGTH], [LIST] )
      • split ( [/PATTERN/], [EXPR], [LIMIT] )
      • sprintf ( FORMAT, LIST )
      • sqrt ( [EXPR] )
      • srand ( [EXPR] )
      • stat ( FILEHANDLE | EXPR )
      • study ( [SCALAR] )
      • substr ( EXPR, OFFSET, [LEN] )
      • symlink ( OLDFILE, NEWFILE )
      • syscall ( LIST )
      • sysopen ( FILEHANDLE, FILENAME, MODE, [PERMISSIONS] )
      • sysread ( FILEHANDLE, BUFFER, LENGTH, [OFFSET] )
      • system ( LIST )
      • syswrite ( FILEHANDLE, BUFFER, LENGTH, [OFFSET] )
      • tell ( [FILEHANDLE] )
      • telldir ( DIRHANDLE )
      • tie ( VARIABLE, PACKAGENAME, LIST )
      • tied ( VARIABLE )
      • time ( )
      • times ( )
      • truncate ( FILEHANDLE | EXPR, LENGTH )
      • uc ( EXPR )
      • ucfirst ( EXPR )
      • umask ( [EXPR] )
      • undef ( [EXPR] )
      • unlink ( LIST )
      • unpack ( TEMPLATE, EXPR )
      • unshift ( ARRAY, LIST )
      • untie ( VARIABLE )
      • utime ( ACCESS_TIME, MODIFICATION_TIME, LIST )
      • values ( HASH )
      • vec ( EXPR, OFFSET, NUM_BITS )
      • wait ( )
      • waitpid ( PID, FLAGS )
      • wantarray ( )
      • warn ( [LIST] )
      • write ( [FILEHANDLE | EXPR] )
  • Appendix D - The Windows Registry
    • Registry Files
      • How to Back Up the Registry
      • How to Restore the Registry
    • Using the Registry
      • Opening an Existing Key
      • Creating a New Key
      • Finding a Key's Value
      • Setting a Key's Name-value Pairs
      • Getting a List of Subkeys
      • Getting a List of Name-Value Pairs
    • Some Common Uses for the Registry
      • Creating a File Association
      • Setting the Icon for a File Extension
      • Enabling the 'new' Context Menu Option
    • Summary
  • Appendix E - What's On the CD?
    • CD Contents Overview
    • Using the Electronic Book
      • Reading the Electronic Book as an HTML Document
      • Installing the Internet Explorer
    • Finding Sample Code