You are previewing Perl by Example, Fourth Edition.
O'Reilly logo
Perl by Example, Fourth Edition

Book Description

“I picked up a copy of JavaScript by Example over the weekend and wanted to thank you for putting out a book that makes JavaScript easy to understand. I’ve been a developer for several years now and JS has always been the “monster under the bed,” so to speak. Your book has answered a lot of questions I’ve had about the inner workings of JS but was afraid to ask. Now all I need is a book that covers Ajax and Coldfusion. Thanks again for putting together an outstanding book.”

Chris Gomez, Web services manager, Zunch Worldwide, Inc.

“I have been reading your UNIX® Shells by Example book, and I must say, it is brilliant. Most other books do not cover all the shells, and when you have to constantly work in an organization that uses tcsh, bash, and korn, it can become very difficult. However, your book has been indispensable to me in learning the various shells and the differences between them…so I thought I’d email you, just to let you know what a great job you have done!”

Farogh-Ahmed Usmani, B.Sc. (Honors), M.Sc., DIC, project consultant (Billing Solutions), Comverse

“I have been learning Perl for about two months now; I have a little shell scripting experience but that is it. I first started with Learning Perl by O’Reilly. Good book but lacking on the examples. I then went to Programming Perl by Larry Wall, a great book for intermediate to advanced, didn’t help me much beginning Perl. I then picked up Perl by Example, Third Edition–this book is a superb, well-written programming book. I have read many computer books and this definitely ranks in the top two, in my opinion. The examples are excellent. The author shows you the code, the output of each line, and then explains each line in every example.”

Dan Patterson, software engineer, GuideWorks, LLC

“Ellie Quigley has written an outstanding introduction to Perl, which I used to learn the language from scratch. All one has to do is work through her examples, putz around with them, and before long, you’re relatively proficient at using the language. Even though I’ve graduated to using Programming Perl by Wall et al., I still find Quigley’s book a most useful reference.”

Casey Machula, support systems analyst, Northern Arizona University, College of Health and Human Services

“When I look at my bookshelf, I see eleven books on Perl programming. Perl by Example, Third Edition, isn’t on the shelf; it sits on my desk, where I use it almost daily. When I bought my copy I had not programmed in several years and my programming was mostly in COBOL so I was a rank beginner at Perl. I had at that time purchased several popular books on Perl but nothing that really put it together for me. I am still no pro, but my book has many dog-eared pages and each one is a lesson I have learned and will certainly remember. “I still think it is the best Perl book on the market for anyone from a beginner to a seasoned programmer using Perl almost daily.”

Bill Maples, network design tools and automations analyst, Fidelity National Information Services

“We are rewriting our intro to OS scripting course and selected your text for the course. It’s an exceptional book. The last time we considered it was a few years ago (second edition). The debugging and system administrator chapters at the end nailed it for us.”

Jim Leone, Ph.D., professor and chair, Information Technology, Rochester Institute of Technology

“Quigley’s book acknowledges a major usage of PHP. To write some kind of front end user interface program that hooks to a back end MySQL database. Both are free and open source, and the combination has proved popular. Especially where the front end involves making an HTML web page with embedded PHP commands. “Not every example involves both PHP and MySQL. Though all examples have PHP. Many demonstrate how to use PHP inside an HTML file. Like writing user-defined functions, or nesting functions. Or making or using function libraries. The functions are a key idea in PHP, that take you beyond the elementary syntax. Functions also let you gainfully use code by other PHP programmers. Important if you are part of a coding group that has to divide up the programming effort in some manner.”

Dr. Wes Boudville, CTO, Metaswarm Inc.

The World’s Easiest Perl Tutorial–Fully Updated!

Perl byExample, Fourth Edition, is the easiest, most hands-on way to learn Perl. Legendary Silicon Valley programming instructor Ellie Quigley has thoroughly updated her classic to deliver the skills and information today’s Perl users need most–including all-new coverage of MySQL database programming and a Perl QuickStart designed to get experienced users up and running fast.

Quigley illuminates every technique with focused, classroom-tested code examples, detailed line-by-line explanations, and real program output. This exceptionally clear, easy-to-understand book takes you from your first Perl script to database-driven applications. It’s the only Perl book you’ll ever need!

New in this edition:

  • Perl programming QuickStart: makes first-time Perl programmers productive in just twenty pages

  • All-new chapter on using the Perl DBI with the MySQL database–plus an easy SQL primer to quickly get you started programming any database

  • New introductions to Perl in biology (bioinformatics) and to mod_perl, a Perl interpreter embedded in the Apache server, which allows you to create fast, dynamic content; manage the Apache server; authenticate users; and much more

  • Completely updated:

  • Includes many new and completely rewritten code examples

  • Contains fully revised CGI coverage for building dynamic Web sites with Perl

  • Covers modern Perl 5.8 concepts and principles–and provide

  • Table of Contents

    1. Copyright
    2. Praise for Ellie Quigley’s Books
    3. Preface
    4. Acknowledgments
    5. 1. The Practical Extraction and Report Language
      1. 1.1. What Is Perl?
      2. 1.2. What Is an Interpreted Language?
      3. 1.3. Who Uses Perl?
        1. 1.3.1. Which Perl?
        2. 1.3.2. What Is Perl 6?
      4. 1.4. Where to Get Perl
        1. 1.4.1. What Version Do I Have?
      5. 1.5. What Is CPAN?
      6. 1.6. Perl Documentation
        1. 1.6.1. Perl Man Pages
        2. 1.6.2. HTML Documentation
      7. 1.7. What You Should Know
      8. 1.8. What’s Next?
    6. 2. Perl Quick Start
      1. 2.1. Quick Start, Quick Reference
        1. 2.1.1. A Note to Programmers
        2. 2.1.2. A Note to Non-Programmers
        3. 2.1.3. Perl Syntax and Constructs
          1. Regular Expressions
          2. Passing Arguments at the Command Line
          3. References, Pointers
          4. Objects
            1. Creating a Class
            2. Instantiating a Class
          5. Libraries and Modules
            1. Path to Libraries
            2. To include a File
          6. Diagnostics
      2. 2.2. Chapter Summary
      3. 2.3. What’s Next?
    7. 3. Perl Scripts
      1. 3.1. Script Setup
      2. 3.2. The Script
        1. 3.2.1. Startup
          1. UNIX/Mac OS
          2. Windows
        2. 3.2.2. Finding a Text Editor
        3. 3.2.3. Naming Perl Scripts
        4. 3.2.4. Statements, Whitespace, and Linebreaks
        5. 3.2.5. Comments
        6. 3.2.6. Perl Statements
        7. 3.2.7. Using Perl Built-in Functions
        8. 3.2.8. Executing the Script
        9. 3.2.9. Sample Script
        10. 3.2.10. What Kinds of Errors to Expect
      3. 3.3. Perl at the Command Line
        1. 3.3.1. The -e Switch
        2. 3.3.2. The -n Switch
          1. Reading from a File
          2. Reading from a Pipe
        3. 3.3.3. The -c Switch
      4. 3.4. What You Should Know
      5. 3.5. What’s Next?
    8. 4. Getting a Handle on Printing
      1. 4.1. The Filehandle
      2. 4.2. Words
      3. 4.3. The print Function
        1. 4.3.1. Quotes
          1. Breaking the Quoting Rules
        2. 4.3.2. Literals (Constants)
          1. Numeric Literals
          2. String Literals
          3. Special Literals
        3. 4.3.3. Printing Literals
          1. Printing Numeric Literals
          2. Printing String Literals
          3. Printing Special Literals
        4. 4.3.4. The warnings Pragma and the -w Switch
        5. 4.3.5. The diagnostics Pragma
        6. 4.3.6. The strict Pragma and Words
      4. 4.4. The printf Function
        1. 4.4.1. The sprintf Function
        2. 4.4.2. Printing without Quotes—The here document
          1. Here Documents and CGI
      5. 4.5. What You Should Know
      6. 4.6. What’s Next?
    9. 5. What’s in a Name
      1. 5.1. About Perl Variables
        1. 5.1.1. Types
        2. 5.1.2. Scope and the Package
        3. 5.1.3. Naming Conventions
        4. 5.1.4. Assignment Statements
        5. 5.1.5. Quoting Rules
          1. Double Quotes
          2. Single Quotes
          3. Backquotes
          4. Perl’s Alternative Quotes
      2. 5.2. Scalars, Arrays, and Hashes
        1. 5.2.1. Scalar Variables
          1. Assignment
          2. Curly Braces
          3. The defined Function
          4. The undef Function
          5. The $_ Scalar Variable
        2. 5.2.2. Arrays
          1. Assignment
          2. Special Scalars and Array Assignment
          3. The Range Operator and Array Assignment
          4. Accessing Elements
          5. Array Slices
          6. Multidimensional Arrays—Lists of Lists
        3. 5.2.3. Hashes
          1. Assignment
          2. Accessing Elements
          3. Hash Slices
        4. 5.2.4. Complex Data Structures
          1. Hashes of Hashes
          2. Array of Hashes
      3. 5.3. Reading from STDIN
        1. 5.3.1. Assigning Input to a Scalar Variable
        2. 5.3.2. The chop and chomp Functions
        3. 5.3.3. The read Function
        4. 5.3.4. The getc Function
        5. 5.3.5. Assigning Input to an Array
        6. 5.3.6. Assigning Input to a Hash
      4. 5.4. Array Functions
        1. 5.4.1. The chop and chomp Functions (with Lists)
        2. 5.4.2. The exists Function
        3. 5.4.3. The delete Function
        4. 5.4.4. The grep Function
        5. 5.4.5. The join Function
        6. 5.4.6. The map Function
        7. 5.4.7. The pack and unpack Functions
        8. 5.4.8. The pop Function
        9. 5.4.9. The push Function
        10. 5.4.10. The shift Function
        11. 5.4.11. The splice Function
        12. 5.4.12. The split Function
        13. 5.4.13. The sort Function
          1. ASCII and Numeric Sort Using Subroutine
          2. Using an Inline Function to Sort a Numeric List
        14. 5.4.14. The reverse Function
        15. 5.4.15. The unshift Function
      5. 5.5. Hash (Associative Array) Functions
        1. 5.5.1. The keys Function
        2. 5.5.2. The values Function
        3. 5.5.3. The each Function
        4. 5.5.4. Sorting a Hash
          1. Sort Hash by Keys in Ascending Order
          2. Sort Hash by Keys in Reverse Order
          3. Sort Hash by Keys Numerically
          4. Numerically Sort a Hash by Values in Ascending Order
          5. Numerically Sort a Hash by Values in Descending Order
        5. 5.5.5. The delete Function
        6. 5.5.6. The exists Function
      6. 5.6. More Hashes
        1. 5.6.1. Loading a Hash from a File
        2. 5.6.2. Special Hashes
          1. The %ENV Hash
          2. The %SIG Hash
          3. The %INC Hash
        3. 5.6.3. Context
      7. 5.7. What You Should Know
      8. 5.8. What’s Next?
    10. 6. Where’s the Operator?
      1. 6.1. About Perl Operators
      2. 6.2. Mixing Data Types
      3. 6.3. Precedence and Associativity
        1. 6.3.1. Assignment Operators
        2. 6.3.2. Relational Operators
          1. Numeric
          2. String
        3. 6.3.3. Equality Operators
          1. Numeric
          2. String
        4. 6.3.4. Logical Operators (Short-Circuit Operators)
        5. 6.3.5. Logical Word Operators
        6. 6.3.6. Arithmetic Operators
        7. 6.3.7. Autoincrement and Autodecrement Operators
        8. 6.3.8. Bitwise Logical Operators
          1. A Little Bit about Bits
          2. Bitwise Operators
        9. 6.3.9. Conditional Operators
        10. 6.3.10. Range Operator
        11. 6.3.11. Special String Operators and Functions
        12. 6.3.12. Arithmetic Functions
          1. Generating Random Numbers
            1. The rand/srand Functions
      4. 6.4. What You Should Know
      5. 6.5. What’s Next?
    11. 7. If Only, Unconditionally, Forever
      1. 7.1. Control Structures, Blocks, and Compound Statements
        1. 7.1.1. Decision Making—Conditional Constructs
          1. if and unless Statements
          2. The if Construct
          3. The if/else Construct
          4. The if/elsif/else Construct
          5. The unless Construct
      2. 7.2. Repetition with Loops
        1. 7.2.1. The while Loop
        2. 7.2.2. The until Loop
          1. The do/while and do/until Loops
        3. 7.2.3. The for Loop
        4. 7.2.4. The foreach Loop
        5. 7.2.5. Loop Control
          1. Labels
          2. A Labeled Block without a Loop
          3. Nested Loops and Labels
          4. The continue Block
        6. 7.2.6. The switch Statement
          1. The Switch.pm Module
      3. 7.3. What You Should Know
      4. 7.4. What’s Next?
    12. 8. Regular Expressions—Pattern Matching
      1. 8.1. What Is a Regular Expression?
      2. 8.2. Expression Modifiers and Simple Statements
        1. 8.2.1. Conditional Modifiers
          1. The if Modifier
        2. 8.2.2. The DATA Filehandle
          1. The unless Modifier
        3. 8.2.3. Looping Modifiers
          1. The while Modifier
          2. The until Modifier
          3. The foreach Modifier
      3. 8.3. Regular Expression Operators
        1. 8.3.1. The m Operator and Matching
          1. The g Modifier—Global Match
          2. The i Modifier—Case Insensitivity
          3. Special Scalars for Saving Patterns
          4. The x Modifier—The Expressive Modifier
        2. 8.3.2. The s Operator and Substitution
          1. Changing the Substitution Delimiters
          2. The g Modifier—Global Substitution
          3. The i Modifier—Case Insensitivity
          4. The e Modifier—Evaluating an Expression
        3. 8.3.3. Pattern Binding Operators
      4. 8.4. What You Should Know
      5. 8.5. What’s Next?
    13. 9. Getting Control—Regular Expression Metacharacters
      1. 9.1. Regular Expression Metacharacters
        1. 9.1.1. Metacharacters for Single Characters
          1. The Dot Metacharacter
          2. The s Modifier—The Dot Metacharacter and the Newline
          3. The Character Class
          4. The POSIX Character Class
        2. 9.1.2. Whitespace Metacharacters
        3. 9.1.3. Metacharacters to Repeat Pattern Matches
          1. The Greed Factor
          2. Metacharacters that Turn off Greediness
          3. Anchoring Metacharacters
          4. The m Modifier
          5. Alternation
          6. Grouping or Clustering
          7. Remembering or Capturing
          8. Turning Off Capturing
          9. Metacharacters that Look Ahead and Behind
        4. 9.1.4. The tr or y Function
          1. The tr Delete Option
          2. The tr Complement Option
          3. The tr Squeeze Option
      2. 9.2. Unicode
        1. 9.2.1. Perl and Unicode
      3. 9.3. What You Should Know
      4. 9.4. What’s Next?
    14. 10. Getting a Handle on Files
      1. 10.1. The User-Defined Filehandle
        1. 10.1.1. Opening Files—The open Function
        2. 10.1.2. Open for Reading
          1. Closing the Filehandle
          2. The die Function
          3. Reading from the Filehandle
        3. 10.1.3. Open for Writing
        4. 10.1.4. Win32 Binary Files
        5. 10.1.5. Open for Appending
        6. 10.1.6. The select Function
        7. 10.1.7. File Locking with flock
        8. 10.1.8. The seek and tell Functions
          1. The seek Function
          2. The tell Function
        9. 10.1.9. Open for Reading and Writing
        10. 10.1.10. Open for Pipes
          1. The Output Filter
          2. Sending the Output of a Filter to a File
          3. Input Filter
      2. 10.2. Passing Arguments
        1. 10.2.1. The ARGV Array
        2. 10.2.2. ARGV and the Null Filehandle
        3. 10.2.3. The eof Function
        4. 10.2.4. The -i Switch—Editing Files in Place
      3. 10.3. File Testing
      4. 10.4. What You Should Know
      5. 10.5. What’s Next?
    15. 11. How Do Subroutines Function?
      1. 11.1. Subroutines/Functions
        1. 11.1.1. Defining and Calling a Subroutine
          1. A Null Parameter List
          2. Forward Reference
          3. Scope of Variables
      2. 11.2. Passing Arguments
        1. Call-by-Reference and the @_ Array
        2. Call-by-Value with local and my
          1. The local Function
          2. The my Operator
        3. Using the strict Pragma (my and our)
        4. 11.2.1. Prototypes
        5. 11.2.2. Return Value
        6. 11.2.3. Context and Subroutines
          1. The wantarray Function and User-Defined Subroutines
      3. 11.3. Call-by-Reference
        1. 11.3.1. Symbolic References—Typeglobs
          1. Definition
          2. Passing by Reference with Aliases
          3. Making Aliases Private—local versus my
          4. Passing Filehandles by Reference
          5. Selective Aliasing and the Backslash Operator
        2. 11.3.2. Hard References—Pointers
          1. Definition
          2. Dereferencing the Pointer
          3. Pointers as Arguments
          4. Passing Pointers to a Subroutine
        3. 11.3.3. Autoloading
        4. 11.3.4. BEGIN and END Subroutines (Startup and Finish)
        5. 11.3.5. The subs Function
      4. 11.4. What You Should Know
      5. 11.5. What’s Next?
    16. 12. Modularize It, Package It, and Send It to the Library!
      1. 12.1. Packages and Modules
        1. 12.1.1. Before Getting Started
        2. 12.1.2. An Analogy
        3. 12.1.3. Definition
        4. 12.1.4. The Symbol Table
      2. 12.2. The Standard Perl Library
        1. 12.2.1. The @INC Array
          1. Setting the PERL5LIB Environment Variable
        2. 12.2.2. Packages and .pl Files
          1. The require Function
          2. Including Standard Library Routines
          3. Using Perl to Include Your Own Library
        3. 12.2.3. Modules and .pm Files
          1. The use Function (Modules and Pragmas)
        4. 12.2.4. Exporting and Importing
          1. The Exporter Module
          2. Using perldoc to Get Documentation for a Perl Module
          3. Using a Perl 5 Module from the Standard Perl Library
        5. 12.2.5. How to “use” a Module from the Standard Perl Library
        6. 12.2.6. Using Perl to Create Your Own Module
      3. 12.3. Modules from CPAN
        1. The Cpan.pm Module
        2. 12.3.1. Using PPM
          1. Creating Extensions and Modules for CPAN with the h2xs Tool
      4. 12.4. What You Should Know
      5. 12.5. What’s Next?
    17. 13. Does This Job Require a Reference?
      1. 13.1. What Is a Reference? What Is a Pointer?
        1. 13.1.1. Symbolic versus Hard References
          1. The strict Pragma
        2. 13.1.2. Hard References, Pointers
          1. The Backslash Operator
          2. Dereferencing the Pointer
        3. 13.1.3. References and Anonymous Variables
          1. Anonymous Arrays
          2. Anonymous Hashes
        4. 13.1.4. Nested Data Structures
          1. Lists of Lists
          2. Array of Hashes
          3. Hash of Hashes
          4. Hash of Hashes with Lists of Values
        5. 13.1.5. References and Subroutines
          1. Anonymous Subroutines
          2. Subroutines and Passing by Reference
        6. 13.1.6. Filehandle References
        7. 13.1.7. The ref Function
      2. 13.2. What You Should Know
      3. 13.3. What’s Next?
    18. 14. Bless Those Things! (Object-Oriented Perl)
      1. 14.1. The OOP Paradigm
        1. 14.1.1. Packages and Modules Revisited
        2. 14.1.2. Some Object-Oriented Lingo
      2. 14.2. Classes, Objects, and Methods
        1. 14.2.1. Real World
        2. 14.2.2. The Steps
        3. 14.2.3. Classes and Privacy
        4. 14.2.4. Objects
          1. The House Class
        5. 14.2.5. The bless Function
        6. 14.2.6. Methods
          1. Definition
          2. Types of Methods
          3. Invoking Methods
            1. Class Method Invocation
            2. Instance Method Invocation
        7. 14.2.7. What an Object-Oriented Module Looks Like
          1. The Class Constructor Method
          2. The Class and Instance Methods
          3. Passing Parameters to Constructor Methods
          4. Passing Parameters to Instance Methods
          5. Named Parameters
            1. The user/driver Program
            2. The Object-Oriented Module
        8. 14.2.8. Polymorphism and Dynamic Binding
          1. The :: versus –> Notation
        9. 14.2.9. Destructors and Garbage Collection
      3. 14.3. Anonymous Subroutines, Closures, and Privacy
        1. 14.3.1. What Is a Closure?
        2. 14.3.2. Closures and Objects
          1. User of the Module
      4. 14.4. Inheritance
        1. 14.4.1. The @ISA Array and Calling Methods
        2. 14.4.2. $AUTOLOAD, sub AUTOLOAD, and UNIVERSAL
        3. 14.4.3. Derived Classes
        4. 14.4.4. Multiple Inheritance
        5. 14.4.5. Overriding a Parent Method
      5. 14.5. Public User Interface—Documenting Classes
        1. 14.5.1. pod Files
        2. 14.5.2. pod Commands
        3. 14.5.3. How to Use the pod Interpreters
        4. 14.5.4. Translating pod Documentation into Text
        5. 14.5.5. Translating pod Documentation into HTML
      6. 14.6. Using Objects from the Perl Library
        1. 14.6.1. Another Look at the Standard Perl Library
        2. 14.6.2. An Object-Oriented Module from the Standard Perl Library
        3. 14.6.3. Using a Module with Objects from the Standard Perl Library
      7. 14.7. What You Should Know
      8. 14.8. What’s Next?
    19. 15. Those Magic Ties and DBM Stuff
      1. 15.1. Tying Variables to a Class
        1. 15.1.1. The tie Function
        2. 15.1.2. Predefined Methods
        3. 15.1.3. Tying a Scalar
        4. 15.1.4. Tying an Array
        5. 15.1.5. Tying a Hash
      2. 15.2. DBM Files
        1. 15.2.1. Creating and Assigning Data to a DBM File
        2. 15.2.2. Retrieving Data from a DBM File
        3. 15.2.3. Deleting Entries from a DBM File
      3. 15.3. What You Should Know
      4. 15.4. What’s Next?
    20. 16. CGI and Perl: The Hyper Dynamic Duo
      1. 16.1. Static and Dynamic Web Pages
      2. 16.2. How It all Works
        1. 16.2.1. Internet Communication between Client and Server
          1. The HTTP Server
          2. HTTP Status Codes and the Access Log File
          3. The URL (Uniform Resource Locator)
          4. File URLs and the Server’s Root Directory
      3. 16.3. Creating a Web Page with HTML
        1. Creating Tags
        2. A Simple HTML Document
      4. 16.4. How HTML and CGI Work Together
        1. 16.4.1. A Simple CGI Script
          1. The HTTP Headers
        2. 16.4.2. Error Log Files
          1. Error Logs and STDERR
      5. 16.5. Getting Information Into and Out of the CGI Script
        1. 16.5.1. CGI Environment Variables
          1. An HTML File with a Link to a CGI Script
      6. 16.6. CGI and Forms
        1. 16.6.1. Input Types for Forms
        2. 16.6.2. Creating an HTML Form
          1. A Simple Form with Text Fields, Radio Buttons, Check Boxes, and Pop-up Menus
        3. 16.6.3. The GET Method
          1. The CGI Script
        4. 16.6.4. Processing the Encoded Data
          1. The Encoded Query String
          2. Decoding the Query String with Perl
          3. Parsing the Form’s Input with Perl
          4. Decoding the Query String
        5. 16.6.5. Putting It All Together
          1. The GET Method
        6. 16.6.6. The POST Method
        7. 16.6.7. Handling E-mail
          1. The SMTP Server
      7. 16.7. The CGI.pm Module
        1. 16.7.1. Introduction
        2. 16.7.2. Advantages
        3. 16.7.3. Two Styles of Programming with CGI.pm
          1. The Object-Oriented Style
          2. Function-Oriented Style
        4. 16.7.4. An Important Warning!
        5. 16.7.5. HTML Form Methods
          1. Creating the HTML Form
        6. 16.7.6. How CGI.pm Works with Forms
          1. The start_html Method
          2. The start_form Method
          3. The submit Method
          4. The param Method
          5. Checking the Form at the Command Line
        7. 16.7.7. CGI.pm Form Elements
        8. 16.7.8. Methods Defined for Generating Form Input Fields
          1. The textfield() Method
          2. The checkbox() Method
          3. The radio_group() and popup_menu() Methods
          4. Labels
          5. The popup_menu() Method
          6. The submit() and reset() Methods
          7. Clearing Fields
            1. The override Argument
            2. The defaults Method
        9. 16.7.9. Error Handling
          1. The carpout and fatalsToBrowser Methods
          2. Changing the Default Message
        10. 16.7.10. HTTP Header Methods
    21. 17. Perl Meets MySQL—A Perfect Connection
      1. 17.1. Introduction
      2. 17.2. What Is a Relational Database?
        1. 17.2.1. Client/Server Databases
        2. 17.2.2. Components of a Relational Database
          1. The Database Server
          2. The Database
          3. Tables
          4. Records and Fields
            1. Columns/Fields
            2. Rows/Records
            3. Primary Key and Indexes
          5. The Database Schema
        3. 17.2.3. Talking to the Database with SQL (the Structured Query Language)
          1. English-like Grammar
          2. Semicolons Terminate SQL Statements
          3. Naming Conventions
          4. Reserved Words
          5. Case Sensitivity
          6. The Result Set
      3. 17.3. Getting Started with MySQL
        1. 17.3.1. Why MySQL?
        2. 17.3.2. Installing MySQL
        3. 17.3.3. Connecting to MySQL
          1. Editing Keys at the MySQL Console
          2. Setting a Password
        4. 17.3.4. Graphical User Tools
          1. The MySQL Query Browser
            1. The phpMyAdmin Tool
          2. The MySQL Privilege System
        5. 17.3.5. Finding the Databases
          1. Creating and Dropping a Database
        6. 17.3.6. Getting Started with Basic Commands
          1. Creating a Database with MySQL
          2. Selecting a Database with MySQL
          3. Creating a Table in the Database
          4. Data Types
          5. Adding Another Table with a Primary Key
          6. Inserting Data into Tables
          7. Selecting Data from Tables—The SELECT Command
          8. Selecting by Columns
          9. Select All Columns
          10. The WHERE Clause
          11. Sorting Tables
          12. Joining Tables
          13. Deleting Rows
          14. Updating Data in a Table
          15. Altering a Table
            1. Add a Column
            2. Drop a Column
            3. Add a Primary Key
          16. Dropping a Table
          17. Dropping a Database
      4. 17.4. What Is the Perl DBI?
        1. 17.4.1. Installing the DBI
          1. DBI-MySQL with PPM
            1. PPM Quickstart
          2. Steps to Install with PPM
          3. The PPM GUI
          4. Using PPM with Linux
          5. Installing DBI Using CPAN
        2. 17.4.2. The DBI Class Methods
        3. 17.4.3. How to Use DBI
        4. 17.4.4. Connecting to and Disconnecting from the Database
          1. The connect() Method
        5. 17.4.5. The disconnect() Method
        6. 17.4.6. Preparing a Statement Handle and Fetching Results
          1. Select, Execute, and Dump the Results
          2. Select, Execute, and Fetch a Row as an Array
          3. Select, Execute, and Fetch a Row as a Hash
        7. 17.4.7. Handling Quotes
        8. 17.4.8. Getting Error Messages
          1. Automatic Error Handling
            1. The PrintError Attribute
            2. The RaiseError Attribute
          2. Manual Error Handling
            1. Error Diagnostic Methods
            2. Error Diagnostic Variables
            3. Examples of Error Messsages
          3. Binding Columns and Fetching Values
            1. Binding Columns
          4. The ? Placeholder
            1. Using a Placeholder
            2. Using Multiple Placeholders
            3. Using Placeholders to Insert Multiple Records
          5. Binding Parameters and the bind_param() Method
          6. Cached Queries
      5. 17.5. Statements that Don’t Return Anything
        1. 17.5.1. The do() method
          1. Adding Entries
          2. Deleting Entries
          3. Updating Entries
      6. 17.6. Transactions
        1. Commit and Rollback
      7. 17.7. Using CGI and the DBI to Select and Display Entries
      8. 17.8. What’s Left?
      9. 17.9. What You Should Know
      10. 17.10. What’s Next?
    22. 18. Interfacing with the System
      1. 18.1. System Calls
        1. 18.1.1. Directories and Files
          1. Backslash Issues
          2. The File::Spec Module
        2. 18.1.2. Directory and File Attributes
          1. UNIX
          2. Windows
        3. 18.1.3. Finding Directories and Files
        4. 18.1.4. Creating a Directory—The mkdir Function
          1. UNIX
          2. Windows
        5. 18.1.5. Removing a Directory—The rmdir Function
        6. 18.1.6. Changing Directories—The chdir Function
        7. 18.1.7. Accessing a Directory via the Directory Filehandle
          1. The opendir Function
          2. The readdir Function
          3. The closedir Function
          4. The telldir Function
          5. The rewinddir Function
          6. The seekdir Function
        8. 18.1.8. Permissions and Ownership
          1. UNIX
          2. Windows
          3. The chmod Function (UNIX)
          4. The chmod Function (Windows)
          5. The chown Function (UNIX)
          6. The umask Function (UNIX)
        9. 18.1.9. Hard and Soft Links
          1. UNIX
          2. Windows
          3. The link and unlink Functions (UNIX)
          4. The symlink and readlink Functions (UNIX)
        10. 18.1.10. Renaming Files
          1. The rename Function (UNIX and Windows)
        11. 18.1.11. Changing Access and Modification Times
          1. The utime Function
        12. 18.1.12. File Statistics
          1. The stat and lstat Functions
        13. 18.1.13. Low-Level File I/O
          1. The read Function (fread)
          2. The sysread and syswrite Functions
          3. The seek Function
          4. The tell Function
        14. 18.1.14. Packing and Unpacking Data
      2. 18.2. Processes
        1. 18.2.1. UNIX Processes
        2. 18.2.2. Win32 Processes
        3. 18.2.3. The Environment (UNIX and Windows)
        4. 18.2.4. Processes and Filehandles
          1. Login Information—The getlogin Function
          2. Special Process Variables (pid, uid, euid, gid, euid)
          3. The Parent Process ID—The getppid Function and the $$ Variable
          4. The Process Group ID—The pgrp Function
        5. 18.2.5. Process Priorities and Niceness
          1. The getpriority Function
          2. The setpriority Function (nice)
        6. 18.2.6. Password Information
          1. UNIX
          2. Windows
          3. Getting a Password Entry (UNIX)—The getpwent Function
          4. Getting a Password Entry by Username—The getpwnam Function
          5. Getting a Password Entry by uid—The getpwuid Function
        7. 18.2.7. Time and Processes
          1. The times function
          2. The time Function (UNIX and Windows)
          3. The gmtime Function
          4. The localtime Function
        8. 18.2.8. Process Creation UNIX
          1. The fork Function
          2. The exec Function
          3. The wait and waitpid Functions
          4. The exit Function
        9. 18.2.9. Process Creation Win32
          1. The start Command
          2. The Win32::Spawn Module
          3. The Win32::Process Module
      3. 18.3. Other Ways to Interface with the Operating System
        1. 18.3.1. The syscall Function and the h2ph Script
        2. 18.3.2. Command Substitution—The Backquotes
        3. 18.3.3. The Shell.pm Module
        4. 18.3.4. The system Function
        5. 18.3.5. here documents
        6. 18.3.6. Globbing (Filename Expansion and Wildcards)
          1. The glob Function
      4. 18.4. Error Handling
        1. The Carp.pm Module
        2. 18.4.1. The die Function
        3. 18.4.2. The warn Function
        4. 18.4.3. The eval Function
          1. Evaluating Perl Expressions with eval
          2. Using eval to Catch Errors in a Program
          3. The eval Function and the here document
      5. 18.5. Signals
        1. Catching Signals
        2. Sending Signals to Processes—The kill Function
        3. The alarm Function
        4. The sleep Function
        5. Attention, Windows Users!
      6. 18.6. What You Should Know
      7. 18.7. What’s Next?
    23. 19. Report Writing with Pictures
      1. 19.1. The Template
        1. 19.1.1. Steps in Defining the Template
        2. 19.1.2. Changing the Filehandle
        3. 19.1.3. Top-of-the-Page Formatting
        4. 19.1.4. The select Function
        5. 19.1.5. Multiline Fields
        6. 19.1.6. Filling Fields
        7. 19.1.7. Dynamic Report Writing
      2. 19.2. What You Should Know
      3. 19.3. What’s Next?
    24. 20. Send It Over the Net and Sock It to ’Em!
      1. 20.1. Networking and Perl
      2. 20.2. Client/Server Model
      3. 20.3. Network Protocols (TCP/IP)
        1. 20.3.1. Ethernet Protocol (Hardware)
        2. 20.3.2. Internet Protocol (IP)
        3. 20.3.3. Transmission Control Protocol (TCP)
        4. 20.3.4. User Datagram Protocol (UDP)
      4. 20.4. Network Addressing
        1. 20.4.1. Ethernet Addresses
        2. 20.4.2. IP Addresses
        3. 20.4.3. Port Numbers
        4. 20.4.4. Perl Protocol Functions
          1. The getprotoent Function
          2. The getprotobyname Function
          3. The getprotobynumber Function
        5. 20.4.5. Perl’s Server Functions
          1. The getservent Function
          2. The getservbyname Function
          3. The getservbyport Function
        6. 20.4.6. Perl’s Host Information Functions
          1. The gethostent Function
          2. The gethostbyaddr Function
          3. The gethostbyname Function
      5. 20.5. Sockets
        1. 20.5.1. Types of Sockets
          1. Stream Sockets
          2. Datagram Sockets
        2. 20.5.2. Socket Domains
          1. The UNIX Domain and the AF_UNIX Family
          2. The Internet Domain and the AF_INET Family
          3. Socket Addresses
        3. 20.5.3. Creating a Socket
        4. 20.5.4. Binding an Address to a Socket Name
          1. The bind Function
        5. 20.5.5. Creating a Socket Queue
          1. The listen Function
        6. 20.5.6. Waiting for a Client Request
          1. The accept Function
        7. 20.5.7. Establishing a Socket Connection
          1. The connect Function
        8. 20.5.8. Socket Shutdown
          1. The shutdown Function
      6. 20.6. Client/Server Programs
        1. 20.6.1. Connection-Oriented Sockets on the Same Machine
          1. The Server Program
          2. The Client Program
        2. 20.6.2. Connection-Oriented Sockets on Remote Machines (Internet Clients and Servers)
      7. 20.7. The Socket.pm Module
        1. The Server
        2. The Client
      8. 20.8. What You Should Know
    25. A. Perl Built-ins, Pragmas, Modules, and the Debugger
      1. A.1. Perl Functions
      2. A.2. Special Variables
      3. A.3. Perl Pragmas
      4. A.4. Perl Modules
      5. A.5. Command-Line Switches
      6. A.6. Debugger
        1. A.6.1. Getting Information about the Debugger
        2. A.6.2. The Perl Debugger
        3. A.6.3. Entering and Exiting the Debugger
        4. A.6.4. Debugger Commands
    26. B. SQL Language Tutorial
      1. B.1. What Is SQL?
        1. B.1.1. Standarizing SQL
        2. B.1.2. Executing SQL Statements
          1. The MySQL Query Browser
        3. B.1.3. About SQL Commands/Queries
          1. English-like Grammar
          2. Semicolons Terminate SQL Statements
          3. Naming Conventions
          4. Reserved Words
          5. Case Senstivity
          6. The Result Set
        4. B.1.4. SQL and the Database
          1. The show databases Command
          2. The USE Command
        5. B.1.5. SQL Database Tables
          1. The SHOW and DESCRIBE Commands
      2. B.2. SQL Data Manipulation Language (DML)
        1. B.2.1. The SELECT Command
          1. Select Specified Columns
          2. Select All Columns
          3. The SELECT DISTINCT Statement
          4. Limiting the Number of Lines in the Result Set with LIMIT
          5. The WHERE Clause
          6. Using Quotes
          7. Using the = and <> Operators
          8. What Is NULL?
          9. The > and < Operators
          10. The AND and OR Operators
          11. The LIKE and NOT LIKE Condition
          12. Pattern Matching and the % Wildcard
          13. The _ Wildcard
          14. The BETWEEN Statement
          15. Sorting Results with ORDER BY
        2. B.2.2. The INSERT Command
        3. B.2.3. The UPDATE Command
        4. B.2.4. The DELETE Statement
      3. B.3. SQL Data Definition Language
        1. B.3.1. Creating the Database
        2. B.3.2. SQL Data Types
        3. B.3.3. Creating a Table
        4. B.3.4. Creating a Key
          1. Primary Keys
          2. Foreign Keys
        5. B.3.5. Relations
          1. Two Tables with a Common Key
          2. Using a Fully Qualified Name and a Dot to Join the Tables
          3. Aliases
        6. B.3.6. Altering a Table
        7. B.3.7. Dropping a Table
        8. B.3.8. Dropping a Database
      4. B.4. SQL Functions
        1. B.4.1. Numeric Functions
          1. Using GROUP BY
        2. B.4.2. String Functions
        3. B.4.3. Date and Time Functions
          1. Formatting the Date and Time
          2. The MySQL EXTRACT Command
      5. B.5. Appendix Summary
      6. B.6. What You Should Know
    27. C. Perl and Biology
      1. C.1. What Is Bioinformatics?
      2. C.2. A Little Background on DNA
      3. C.3. Some Perl Examples
      4. C.4. What Is BioPerl?
      5. C.5. Resources
    28. D. Power and Speed: CGI and mod_perl
      1. D.1. What Is mod_perl?
      2. D.2. The mod_perl Web Site
        1. What Is mod_perl?
          1. Success Stories
          2. Download
          3. Documentation
          4. Reporting Bugs
          5. Getting Help
          6. Mailing Lists
          7. Products
          8. Contribute
          9. Got mod_perl?
          10. About mod_perl
          11. mod_perl Subprojects
          12. Jobs
          13. Site Map
      3. D.3. Installing mod_perl
        1. Installing mod_perl for ActiveState with PPM
          1. Apache’s conf Directory (Configuration Files)
          2. Editing Apache’s httpd.conf File
        2. Create the Locations for mod_perl Scripts
          1. Where Are the Apache Perl Modules Stored?
          2. The PerlRequire Directive
          3. Editing Apache’s httpd.conf File
        3. Is mod_perl Installed?
          1. Testing mod_perl with a CGI Script
        4. UNIX/Linux Installation
        5. mod_perl Documentation
          1. Conventions Used in the mod_perl Documentation
          2. mod_perl 1.0 Documentation
          3. mod_perl 2.0 Documentation
          4. General Documentation
          5. Offsite Resources
      4. D.4. Resources