Perl by Example 2nd Ed.

Ellie Quigley

Publisher: Prentice Hall, 1997, 552 pages

ISBN: 0-13-655689-2

Keywords: Perl

Last modified: March 20, 2022, 9:28 p.m.

Perl — Now more than ever!

When the first edition of Perl by Example was published a few years ago, Perl was a trade secret of UNIX® programmers who wanted to combine the power of grep, awk, sed, tr, shells, and C in a single easy language. These days it's everywhere, as the source language for the CGI scripts that make the Internet go 'round.

This second edition of Perl by Example is completely revised and updated to bring you up to the minute with:

  • Complete coverage of Perl 5
  • Bug fixes to existing versions
  • Full treatment of CGI scripting

Written with the same friendly tone and filled with practical examples, Perl by Example still focuses on bringing you practical information without a lot of fluff. From basic scripting to complex network applications, you'll maximize your learning with:

  • Hands-on tutorials, from simple reports to sophisticated Perl scripts
  • One-to-one comparisons with other familiar languages and utilities
  • Convenient reference for ongoing learning
  1. The Practical Extraction Report Language
    1. What Is Perl?
    2. Who Uses Perl?
    3. Which Perl?
    4. Where to Get Perl?
      1. What Version Do I Have?
  2. Perl Scripts
    1. Perl at the Command Line
      1. The -e Switch
      2. The -n Switch
      3. The -c Switch
    2. Script Setup
    3. The Script
      1. Startup and The #! Line
      2. Comments
      3. Perl Statement
      4. Executing the Script
      5. Sample Script
  3. Getting a Handle on printing
    1. The Filehandle
    2. Words
      1. Quotes
      2. Literals
    3. The print Function
      1. Printing Literals
      2. The -w Switch
      3. The Strict Pragma and Words
    4. The printf Function
      1. Printing Without Quotes — The Here Document
  4. What's in a Name?
    1. About Perl Variables
      1. Types
      2. Scope and the Package
      3. Naming Conventions
      4. Assignment Statements
      5. Quoting Rules
    2. Scalars, Arrays, and Hashes
      1. Scalar Variables
      2. Arrays
      3. Associative Arrays (Hashes)
    3. Reading from STDIN
      1. Assigning Input to a Scalar Variable
      2. The chop and the chomp Functions
      3. Assigning Input to an Array
      4. Assigning Input to an Associative Array
    4. Array Functions
      1. The chop and chomp Functions (With Lists)
      2. The grep Function
      3. The join Function
      4. the pop Function
      5. The push Function
      6. The shift Function
      7. The splice Function
      8. The split Function
      9. The sort Function
      10. The reverse Function
      11. The unshift Function
    5. Associative Array Functions
      1. The keys Function
      2. The values Function
      3. The each Function
      4. The delete Function
    6. More Associative Arrays
      1. Loading an Associative Array from a File
      2. Special Associative Arrays
      3. The %INC Associative Array
  5. Where's the Operator?
    1. About Perl Operators
    2. Mixing Data Types
    3. Precedence and Associativity
      1. Assignment Operators
      2. Relational Operators
      3. Equality Operators
      4. Logical Operators (Short-Circuit Operators)
      5. Arithmetic Operators
      6. Autoincrement and Autodecrement Operators
      7. Bitwise Logical Operators
      8. Conditional Operator
      9. Range Operator
      10. Special String Operators and Functions
  6. Regular Expressions — They're Back!
    1. What Is a Regular Expression?
    2. Expression Modifiers and Simple Statements
      1. Conditional Modifiers
      2. Looping Modifiers
    3. Regular Expression Operators
      1. The m Operator
      2. The s Operator
      3. Pattern Binding Operators
    4. Regular Expression Metacharacters
      1. The tr or y Function
  7. If Only, Unconditionally, Forever
    1. Control Structures, Blocks, and Compound Statements
    2. Decision Making — Conditional Constructs
      1. if and unless Statements
      2. The unless Construct
    3. Loops
      1. The while Loop
      2. The until Loop
      3. The for Loop
      4. The foreach Loop
      5. Loop Control
      6. The Phoney Switch statement
  8. Getting a Handle on Files
    1. The User-Defined Filehandle
      1. Opening Files — the Open Function
      2. open for reading
      3. Closing the Filehandle
      4. open for Writing
      5. open for Appending
      6. The select Function
      7. File Locking with flock
      8. open for Pipes
      9. The seek and tell Functions
    2. Passing Arguments
      1. The ARGV Array
      2. ARGV and the Null Filehandle
      3. The eof Function
      4. The -i Switch — Editing Files in Place
    3. File Testing
  9. Modularize It, Package It, and Send It to the Library!
    1. Subroutine Definition
    2. Passing Arguments
      1. Call by Reference
      2. Passing by Value
      3. Return Value
      4. Aliases and Typeglob
      5. Autoloading
      6. BEGIN and END Subroutines (Startup and Finish)
      7. The subs Function
    3. Packages and Modules
      1. Definition
      2. The Symbol Table
      3. Using Packages
    4. The Standard Perl Library
      1. The @INC Array
      2. Packages and .pl Files
      3. Module and .pm Files
  10. Does This Job Require a Reference?
    1. What Is a Reference?
      1. Symbolic vs. Hard References
      2. Passing Arrays by References
      3. References and Anonymous Variables
      4. The ref Function
  11. Bless Those Things! (Object-Oriented Perl5)
    1. The OOP Paradigm
      1. Packages and Modules Revisited
      2. Some Object-Oriented Lingo
    2. Objects, Methods, and Classes
      1. Classes and Privacy
    3. Objects — Blessed references
    4. Methods
      1. Definition
      2. Invoking Methods
      3. The Class Method — Constructor
      4. The Class and Instance Methods
      5. Passing Parameters to Constructor Methods
      6. Passing Parameters to Instance Methods
      7. Destructors and Garbage Collection
    5. Inheritance
      1. The @ISA Array and Calling Methods
      2. $AUTOLOAD , sub AUTOLOAD, and UNIVERSAL
      3. Derived Classes
      4. Multiple Inheritance
      5. Overriding a Parent Method
    6. Using Objects from the Perl Library
      1. Another Look at the Standard Perl Library
      2. An Object-Oriented Module from the Standard Perl Library
      3. Using a Module with Objects from the Standard Perl Library
  12. Interfacing with the System
    1. System Calls
    2. Directories and Files
      1. Making and Removing Directories
      2. Permissions and Ownership
      3. Hard and Soft Links
      4. Renaming Files
      5. Changing Access and Modification Times
      6. File Statistics
      7. Low Level File I/O
      8. Packing and Unpacking Data
    3. Processes
      1. The Environment
      2. Password Information
      3. Time and Processes
      4. Process Creation
      5. The fork Function
      6. The exec Function
      7. The wait and waitpid Functions
      8. The exit Function
    4. Other Ways to Interface with UNIX
      1. The syscall Function and the h2ph Script
      2. Command Substitution — The Back Quotes
      3. The system Function
      4. Here Documents
      5. Globbing (Filename Expansion and Wild Cards)
    5. Error Handling
      1. The die Function
      2. The warn Function
      3. The eval Function
    6. Signals
  13. Report Writing with Pictures
    1. The Template
      1. Steps in Defining the Template
    2. Changing the Filehandle
    3. Top-of-the-Page Formatting
    4. The select Function
    5. Multiline Fields
    6. Filling Fields
    7. Formatting Perl DBM Databases
  14. Send It over the Net and Socket to 'em
    1. Networking and Perl
    2. Client/Server Model
    3. Network Protocols (TCP/IP)
      1. Ethernet Protocol (Hardware)
      2. Internet protocol (IP)
      3. Transmission Control Protocol (TCP)
      4. User Datagram Protocol (UDP)
    4. Network Addressing
      1. Perl Protocol Functions
      2. Perl's Server Functions
      3. Perl's Host Information Functions
    5. Sockets
      1. Types of Sockets
      2. Socket Domains
      3. Creating a Socket
      4. Binding an Address to a Socket Name
      5. Creating a Socket Queue
      6. Waiting for a Client request
      7. Establishing a Socket Connection
      8. Socket Shutdown
    6. Client/Server Programs
      1. Connection-Oriented Sockets on the Same Machine
      2. Connection-Oriented Sockets on Remote Machines (Internet Clients and Servers)
    7. The Socket.pm Module
  15. Message Queues, Semaphores, and Shared Memory
    1. The IPC Objects
      1. Common Features
      2. IPC User Commands
      3. Size Limits
      4. Required Header Files — The h2ph Script
    2. Message Queues
    3. Semaphores
    4. Shared Memory
  16. The Hyper Dynamic Duo (CGI and Perl)
    1. What Is CGI
    2. The HTTP Server
      1. The URL (Uniform Resource Locator)
    3. Short Introduction to HTML
      1. HTTP Status Codes and the Logfiles
    4. A Simple HTML Document
    5. How HTML and CGI Work Together
      1. A Simple CGI Script
    6. Where to Find CGI Applications
    7. Getting Information Into and Out the CGI Script
      1. CGI Environment Variables
    8. Forms
      1. The GET Method
      2. The Encoded Query String
      3. Decoding the Query String with Perl
      4. The POST Method
      5. Extra Path Information
      6. Server Side Includes
    9. Using the CGI-lib.pl Library
    10. The CGI-lib.pm Module
    11. Cookies
      1. What's a Cookie?
      2. Making Cookies
  • Appendix A
    1. Perl Functions
    2. Special Variables
      1. Filehandles
      2. Local to Block
      3. Global
    3. Perl Pragmas
    4. Perl Modules
    5. Command Line Switches
    6. Debugger
    7. Perl Translators
      1. Awk to Perl Example
      2. SED to Perl Example
    8. Plain Old Documentation — POD
  • Appendix B
    1. taintperl script
      1. Program by Max Houser
    2. maxpstat
      1. Program by John J. Nouveaux
    3. randomize
      1. Program by John J. Nouveaux

Reviews

Perl by Example

Reviewed by Roland Buresund

Good ******* (7 out of 10)

Last modified: Nov. 15, 2008, 11:29 a.m.

Excellent introduction.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required