Books & Videos

Table of Contents

  1. Chapter 1 Strings

    1. Introduction

    2. Accessing Substrings

    3. Establishing a Default Value

    4. Exchanging Values Without Using Temporary Variables

    5. Converting Between Characters and Values

    6. Using Named Unicode Characters

    7. Processing a String One Character at a Time

    8. Reversing a String by Word or Character

    9. Treating Unicode Combined Characters as Single Characters

    10. Canonicalizing Strings with Unicode Combined Characters

    11. Treating a Unicode String as Octets

    12. Expanding and Compressing Tabs

    13. Expanding Variables in User Input

    14. Controlling Case

    15. Properly Capitalizing a Title or Headline

    16. Interpolating Functions and Expressions Within Strings

    17. Indenting Here Documents

    18. Reformatting Paragraphs

    19. Escaping Characters

    20. Trimming Blanks from the Ends of a String

    21. Parsing Comma-Separated Data

    22. Constant Variables

    23. Soundex Matching

    24. Program: fixstyle

    25. Program: psgrep

  2. Chapter 2 Numbers

    1. Introduction

    2. Checking Whether a String Is a Valid Number

    3. Rounding Floating-Point Numbers

    4. Comparing Floating-Point Numbers

    5. Operating on a Series of Integers

    6. Working with Roman Numerals

    7. Generating Random Numbers

    8. Generating Repeatable Random Number Sequences

    9. Making Numbers Even More Random

    10. Generating Biased Random Numbers

    11. Doing Trigonometry in Degrees, Not Radians

    12. Calculating More Trigonometric Functions

    13. Taking Logarithms

    14. Multiplying Matrices

    15. Using Complex Numbers

    16. Converting Binary, Octal, and Hexadecimal Numbers

    17. Putting Commas in Numbers

    18. Printing Correct Plurals

    19. Program: Calculating Prime Factors

  3. Chapter 3 Dates and Times

    1. Introduction

    2. Finding Today's Date

    3. Converting DMYHMS to Epoch Seconds

    4. Converting Epoch Seconds to DMYHMS

    5. Adding to or Subtracting from a Date

    6. Difference of Two Dates

    7. Day in a Week/Month/Year or Week Number

    8. Parsing Dates and Times from Strings

    9. Printing a Date

    10. High-Resolution Timers

    11. Short Sleeps

    12. Program: hopdelta

  4. Chapter 4 Arrays

    1. Introduction

    2. Specifying a List in Your Program

    3. Printing a List with Commas

    4. Changing Array Size

    5. Implementing a Sparse Array

    6. Iterating Over an Array

    7. Iterating Over an Array by Reference

    8. Extracting Unique Elements from a List

    9. Finding Elements in One Array but Not Another

    10. Computing Union, Intersection, or Difference of Unique Lists

    11. Appending One Array to Another

    12. Reversing an Array

    13. Processing Multiple Elements of an Array

    14. Finding the First List Element That Passes a Test

    15. Finding All Elements in an Array Matching Certain Criteria

    16. Sorting an Array Numerically

    17. Sorting a List by Computable Field

    18. Implementing a Circular List

    19. Randomizing an Array

    20. Program: words

    21. Program: permute

  5. Chapter 5 Hashes

    1. Introduction

    2. Adding an Element to a Hash

    3. Testing for the Presence of a Key in a Hash

    4. Creating a Hash with Immutable Keys or Values

    5. Deleting from a Hash

    6. Traversing a Hash

    7. Printing a Hash

    8. Retrieving from a Hash in Insertion Order

    9. Hashes with Multiple Values per Key

    10. Inverting a Hash

    11. Sorting a Hash

    12. Merging Hashes

    13. Finding Common or Different Keys in Two Hashes

    14. Hashing References

    15. Presizing a Hash

    16. Finding the Most Common Anything

    17. Representing Relationships Between Data

    18. Program: dutree

  6. Chapter 6 Pattern Matching

    1. Introduction

    2. Copying and Substituting Simultaneously

    3. Matching Letters

    4. Matching Words

    5. Commenting Regular Expressions

    6. Finding the Nth Occurrence of a Match

    7. Matching Within Multiple Lines

    8. Reading Records with a Separator

    9. Extracting a Range of Lines

    10. Matching Shell Globs as Regular Expressions

    11. Speeding Up Interpolated Matches

    12. Testing for a Valid Pattern

    13. Honoring Locale Settings in Regular Expressions

    14. Approximate Matching

    15. Matching from Where the Last Pattern Left Off

    16. Greedy and Non-Greedy Matches

    17. Detecting Doubled Words

    18. Matching Nested Patterns

    19. Expressing AND, OR, and NOT in a Single Pattern

    20. Matching a Valid Mail Address

    21. Matching Abbreviations

    22. Program: urlify

    23. Program: tcgrep

    24. Regular Expression Grab Bag

  7. Chapter 7 File Access

    1. Introduction

    2. Opening a File

    3. Opening Files with Unusual Filenames

    4. Expanding Tildes in Filenames

    5. Making Perl Report Filenames in Error Messages

    6. Storing Filehandles into Variables

    7. Writing a Subroutine That Takes Filehandles as Built-ins Do

    8. Caching Open Output Filehandles

    9. Printing to Many Filehandles Simultaneously

    10. Opening and Closing File Descriptors by Number

    11. Copying Filehandles

    12. Creating Temporary Files

    13. Storing a File Inside Your Program Text

    14. Storing Multiple Files in the DATA Area

    15. Writing a Unix-Style Filter Program

    16. Modifying a File in Place with a Temporary File

    17. Modifying a File in Place with the -i Switch

    18. Modifying a File in Place Without a Temporary File

    19. Locking a File

    20. Flushing Output

    21. Doing Non-Blocking I/O

    22. Determining the Number of Unread Bytes

    23. Reading from Many Filehandles Without Blocking

    24. Reading an Entire Line Without Blocking

    25. Program: netlock

    26. Program: lockarea

  8. Chapter 8 File Contents

    1. Introduction

    2. Reading Lines with Continuation Characters

    3. Counting Lines (or Paragraphs or Records) in a File

    4. Processing Every Word in a File

    5. Reading a File Backward by Line or Paragraph

    6. Trailing a Growing File

    7. Picking a Random Line from a File

    8. Randomizing All Lines

    9. Reading a Particular Line in a File

    10. Processing Variable-Length Text Fields

    11. Removing the Last Line of a File

    12. Processing Binary Files

    13. Using Random-Access I/O

    14. Updating a Random-Access File

    15. Reading a String from a Binary File

    16. Reading Fixed-Length Records

    17. Reading Configuration Files

    18. Testing a File for Trustworthiness

    19. Treating a File as an Array

    20. Setting the Default I/O Layers

    21. Reading or Writing Unicode from a Filehandle

    22. Converting Microsoft Text Files into Unicode

    23. Comparing the Contents of Two Files

    24. Pretending a String Is a File

    25. Program: tailwtmp

    26. Program: tctee

    27. Program: laston

    28. Program: Flat File Indexes

  9. Chapter 9 Directories

    1. Introduction

    2. Getting and Setting Timestamps

    3. Deleting a File

    4. Copying or Moving a File

    5. Recognizing Two Names for the Same File

    6. Processing All Files in a Directory

    7. Globbing, or Getting a List of Filenames Matching a Pattern

    8. Processing All Files in a Directory Recursively

    9. Removing a Directory and Its Contents

    10. Renaming Files

    11. Splitting a Filename into Its Component Parts

    12. Working with Symbolic File Permissions Instead of Octal Values

    13. Program: symirror

    14. Program: lst

  10. Chapter 10 Subroutines

    1. Introduction

    2. Accessing Subroutine Arguments

    3. Making Variables Private to a Function

    4. Creating Persistent Private Variables

    5. Determining Current Function Name

    6. Passing Arrays and Hashes by Reference

    7. Detecting Return Context

    8. Passing by Named Parameter

    9. Skipping Selected Return Values

    10. Returning More Than One Array or Hash

    11. Returning Failure

    12. Prototyping Functions

    13. Handling Exceptions

    14. Saving Global Values

    15. Redefining a Function

    16. Trapping Undefined Function Calls with AUTOLOAD

    17. Nesting Subroutines

    18. Writing a Switch Statement

    19. Program: Sorting Your Mail

  11. Chapter 11 References and Records

    1. Introduction

    2. Taking References to Arrays

    3. Making Hashes of Arrays

    4. Taking References to Hashes

    5. Taking References to Functions

    6. Taking References to Scalars

    7. Creating Arrays of Scalar References

    8. Using Closures Instead of Objects

    9. Creating References to Methods

    10. Constructing Records

    11. Reading and Writing Hash Records to Text Files

    12. Printing Data Structures

    13. Copying Data Structures

    14. Storing Data Structures to Disk

    15. Transparently Persistent Data Structures

    16. Coping with Circular Data Structures Using Weak References

    17. Program: Outlines

    18. Program: Binary Trees

  12. Chapter 12 Packages, Libraries, and Modules

    1. Introduction

    2. Defining a Module's Interface

    3. Trapping Errors in require or use

    4. Delaying use Until Runtime

    5. Making Variables Private to a Module

    6. Making Functions Private to a Module

    7. Determining the Caller's Package

    8. Automating Module Cleanup

    9. Keeping Your Own Module Directory

    10. Preparing a Module for Distribution

    11. Speeding Module Loading with SelfLoader

    12. Speeding Up Module Loading with Autoloader

    13. Overriding Built-in Functions

    14. Overriding a Built-in Function in All Packages

    15. Reporting Errors and Warnings Like Built-ins

    16. Customizing Warnings

    17. Referring to Packages Indirectly

    18. Using h2ph to Translate C #include Files

    19. Using h2xs to Make a Module with C Code

    20. Writing Extensions in C with Inline::C

    21. Documenting Your Module with Pod

    22. Building and Installing a CPAN Module

    23. Example: Module Template

    24. Program: Finding Versions and Descriptions of Installed Modules

  13. Chapter 13 Classes, Objects, and Ties

    1. Introduction

    2. Constructing an Object

    3. Destroying an Object

    4. Managing Instance Data

    5. Managing Class Data

    6. Using Classes as Structs

    7. Cloning Constructors

    8. Copy Constructors

    9. Invoking Methods Indirectly

    10. Determining Subclass Membership

    11. Writing an Inheritable Class

    12. Accessing Overridden Methods

    13. Generating Attribute Methods Using AUTOLOAD

    14. Coping with Circular Data Structures Using Objects

    15. Overloading Operators

    16. Creating Magic Variables with tie

  14. Chapter 14 Database Access

    1. Introduction

    2. Making and Using a DBM File

    3. Emptying a DBM File

    4. Converting Between DBM Files

    5. Merging DBM Files

    6. Sorting Large DBM Files

    7. Storing Complex Data in a DBM File

    8. Persistent Data

    9. Saving Query Results to Excel or CSV

    10. Executing an SQL Command Using DBI

    11. Escaping Quotes

    12. Dealing with Database Errors

    13. Repeating Queries Efficiently

    14. Building Queries Programmatically

    15. Finding the Number of Rows Returned by a Query

    16. Using Transactions

    17. Viewing Data One Page at a Time

    18. Querying a CSV File with SQL

    19. Using SQL Without a Database Server

    20. Program: ggh—Grep Netscape Global History

  15. Chapter 15 Interactivity

    1. Introduction

    2. Parsing Program Arguments

    3. Testing Whether a Program Is Running Interactively

    4. Clearing the Screen

    5. Determining Terminal or Window Size

    6. Changing Text Color

    7. Reading Single Characters from the Keyboard

    8. Ringing the Terminal Bell

    9. Using POSIX termios

    10. Checking for Waiting Input

    11. Reading Passwords

    12. Editing Input

    13. Managing the Screen

    14. Controlling Another Program with Expect

    15. Creating Menus with Tk

    16. Creating Dialog Boxes with Tk

    17. Responding to Tk Resize Events

    18. Removing the DOS Shell Window with Windows Perl/Tk

    19. Graphing Data

    20. Thumbnailing Images

    21. Adding Text to an Image

    22. Program: Small termcap Program

    23. Program: tkshufflepod

    24. Program: graphbox

  16. Chapter 16 Process Management and Communication

    1. Introduction

    2. Gathering Output from a Program

    3. Running Another Program

    4. Replacing the Current Program with a Different One

    5. Reading or Writing to Another Program

    6. Filtering Your Own Output

    7. Preprocessing Input

    8. Reading STDERR from a Program

    9. Controlling Input and Output of Another Program

    10. Controlling the Input, Output, and Error of Another Program

    11. Communicating Between Related Processes

    12. Making a Process Look Like a File with Named Pipes

    13. Sharing Variables in Different Processes

    14. Listing Available Signals

    15. Sending a Signal

    16. Installing a Signal Handler

    17. Temporarily Overriding a Signal Handler

    18. Writing a Signal Handler

    19. Catching Ctrl-C

    20. Avoiding Zombie Processes

    21. Blocking Signals

    22. Timing Out an Operation

    23. Turning Signals into Fatal Errors

    24. Program: sigrand

  17. Chapter 17 Sockets

    1. Introduction

    2. Writing a TCP Client

    3. Writing a TCP Server

    4. Communicating over TCP

    5. Setting Up a UDP Client

    6. Setting Up a UDP Server

    7. Using Unix Domain Sockets

    8. Identifying the Other End of a Socket

    9. Finding Your Own Name and Address

    10. Closing a Socket After Forking

    11. Writing Bidirectional Clients

    12. Forking Servers

    13. Pre-Forking Servers

    14. Non-Forking Servers

    15. Multitasking Server with Threads

    16. Writing a Multitasking Server with POE

    17. Writing a Multihomed Server

    18. Making a Daemon Server

    19. Restarting a Server on Demand

    20. Managing Multiple Streams of Input

    21. Program: backsniff

    22. Program: fwdport

  18. Chapter 18 Internet Services

    1. Introduction

    2. Simple DNS Lookups

    3. Being an FTP Client

    4. Sending Mail

    5. Reading and Posting Usenet News Messages

    6. Reading Mail with POP3

    7. Simulating Telnet from a Program

    8. Pinging a Machine

    9. Accessing an LDAP Server

    10. Sending Attachments in Mail

    11. Extracting Attachments from Mail

    12. Writing an XML-RPC Server

    13. Writing an XML-RPC Client

    14. Writing a SOAP Server

    15. Writing a SOAP Client

    16. Program: rfrm

    17. Program: expn and vrfy

  19. Chapter 19 CGI Programming

    1. Introduction

    2. Writing a CGI Script

    3. Redirecting Error Messages

    4. Fixing a 500 Server Error

    5. Writing a Safe CGI Program

    6. Executing Commands Without Shell Escapes

    7. Formatting Lists and Tables with HTML Shortcuts

    8. Redirecting to a Different Location

    9. Debugging the Raw HTTP Exchange

    10. Managing Cookies

    11. Creating Sticky Widgets

    12. Writing a Multiscreen CGI Script

    13. Saving a Form to a File or Mail Pipe

    14. Program: chemiserie

  20. Chapter 20 Web Automation

    1. Introduction

    2. Fetching a URL from a Perl Script

    3. Automating Form Submission

    4. Extracting URLs

    5. Converting ASCII to HTML

    6. Converting HTML to ASCII

    7. Extracting or Removing HTML Tags

    8. Finding Stale Links

    9. Finding Fresh Links

    10. Using Templates to Generate HTML

    11. Mirroring Web Pages

    12. Creating a Robot

    13. Parsing a Web Server Log File

    14. Processing Server Logs

    15. Using Cookies

    16. Fetching Password-Protected Pages

    17. Fetching https:// Web Pages

    18. Resuming an HTTP GET

    19. Parsing HTML

    20. Extracting Table Data

    21. Program: htmlsub

    22. Program: hrefsub

  21. Chapter 21 mod_perl

    1. Introduction

    2. Authenticating

    3. Setting Cookies

    4. Accessing Cookie Values

    5. Redirecting the Browser

    6. Interrogating Headers

    7. Accessing Form Parameters

    8. Receiving Uploaded Files

    9. Speeding Up Database Access

    10. Customizing Apache's Logging

    11. Transparently Storing Information in URLs

    12. Communicating Between mod_perl and PHP

    13. Migrating from CGI to mod_perl

    14. Sharing Information Between Handlers

    15. Reloading Changed Modules

    16. Benchmarking a mod_perl Application

    17. Templating with HTML::Mason

    18. Templating with Template Toolkit

  22. Chapter 22 XML

    1. Introduction

    2. Parsing XML into Data Structures

    3. Parsing XML into a DOM Tree

    4. Parsing XML into SAX Events

    5. Making Simple Changes to Elements or Text

    6. Validating XML

    7. Finding Elements and Text Within an XML Document

    8. Processing XML Stylesheet Transformations

    9. Processing Files Larger Than Available Memory

    10. Reading and Writing RSS Files

    11. Writing XML

  1. Colophon