Advanced Perl Programming, 2nd Edition

Book description

With a worldwide community of users and more than a million dedicated programmers, Perl has proven to be the most effective language for the latest trends in computing and business.

Every programmer must keep up with the latest tools and techniques. This updated version of Advanced Perl Programming from O'Reilly gives you the essential knowledge of the modern Perl programmer. Whatever your current level of Perl expertise, this book will help you push your skills to the next level and become a more accomplished programmer.

O'Reilly's most high-level Perl tutorial to date, Advanced Perl Programming, Second Edition teaches you all the complex techniques for production-ready Perl programs. This completely updated guide clearly explains concepts such as introspection, overriding built-ins, extending Perl's object-oriented model, and testing your code for greater stability.

Other topics include:

  • Complex data structures
  • Parsing
  • Templating toolkits
  • Working with natural language data
  • Unicode
  • Interaction with C and other languages
In addition, this guide demystifies once complex topics like object-relational mapping and event-based development-arming you with everything you need to completely upgrade your skills.

Praise for the Second Edition:

"Sometimes the biggest hurdle to problem solving isn't the subject itself but rather the sheer number of modules Perl provides. Advanced Perl Programming walks you through Perl's TMTOWTDI ("There's More Than One Way To Do It") forest, explaining and comparing the best modules for each task so you can intelligently apply them in a variety of situations." --Rocco Caputo, lead developer of POE

"It has been said that sufficiently advanced Perl code is indistinguishable from magic. This book of spells goes a long way to unlocking those secrets. It has the power to transform the most humble programmer into a Perl wizard." --Andy Wardley

"The information here isn't theoretical. It presents tools and techniques for solving real problems cleanly and elegantly." --Curtis 'Ovid' Poe

" Advanced Perl Programming collects hard-earned knowledge from some of the best programmers in the Perl community, and explains it in a way that even novices can apply immediately." --chromatic, Editor of Perl.com

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Audience
    2. Contents
    3. Conventions Used in This Book
    4. Using Code Examples
    5. We’d Like to Hear from You
    6. Safari® Enabled
    7. Acknowledgments
  2. 1. Advanced Techniques
    1. 1.1. Introspection
      1. 1.1.1. Preparatory Work: Fun with Globs
        1. 1.1.1.1. Aliasing
        2. 1.1.1.2. Accessing parts of a glob
        3. 1.1.1.3. Creating subroutines with glob assignment
      2. 1.1.2. AUTOLOAD
      3. 1.1.3. CORE and CORE::GLOBAL
      4. 1.1.4. Case Study: Hook::LexWrap
      5. 1.1.5. Introspection with B
    2. 1.2. Messing with the Class Model
      1. 1.2.1. UNIVERSAL
      2. 1.2.2. Dynamic Method Resolution
      3. 1.2.3. Case Study: Singleton Methods
    3. 1.3. Unexpected Code
      1. 1.3.1. Overloading
        1. 1.3.1.1. Simple operator overloading
        2. 1.3.1.2. Other operator overloading
        3. 1.3.1.3. Non-operator overloading
      2. 1.3.2. Time Shifting
        1. 1.3.2.1. Doing things now with eval/BEGIN
        2. 1.3.2.2. Doing things later with CHECK
        3. 1.3.2.3. Doing things at the end with DESTROY
        4. 1.3.2.4. Case study: Acme::Dot
    4. 1.4. Conclusion
  3. 2. Parsing Techniques
    1. 2.1. Parse::RecDescent Grammars
      1. 2.1.1. Simple Parsing with Parse::RecDescent
        1. 2.1.1.1. Types of match
        2. 2.1.1.2. Actions
      2. 2.1.2. Debugging
      3. 2.1.3. More Difficult Parsing
        1. 2.1.3.1. Commit, reject, and error
        2. 2.1.3.2. Syntactic whitespace
        3. 2.1.3.3. Automating the process
        4. 2.1.3.4. And much more...
      4. 2.1.4. Some Examples
        1. 2.1.4.1. Parsing iCalendar data
        2. 2.1.4.2. .procmailrc
    2. 2.2. Parse::Yapp
    3. 2.3. Other Parsing Techniques
      1. 2.3.1. HTML::Parser
      2. 2.3.2. XML Parsing
      3. 2.3.3. And Everything Else...
    4. 2.4. Conclusion
  4. 3. Templating Tools
    1. 3.1. Formats and Text::Autoformat
      1. 3.1.1. Text::Autoformat
    2. 3.2. Text::Template
      1. 3.2.1. Loops, Arrays, and Hashes
      2. 3.2.2. Security and Error Checking
      3. 3.2.3. Text::Template Tricks
    3. 3.3. HTML::Template
      1. 3.3.1. Variables and Conditions
      2. 3.3.2. Loops
      3. 3.3.3. RSS Aggregation
    4. 3.4. HTML::Mason
      1. 3.4.1. Basic Components
      2. 3.4.2. Basic Dynamism
      3. 3.4.3. Perl Blocks
      4. 3.4.4. Our RSS Aggregator
    5. 3.5. Template Toolkit
      1. 3.5.1. Filters
      2. 3.5.2. Plugins
      3. 3.5.3. Components and Macros
      4. 3.5.4. The RSS Aggregator
    6. 3.6. AxKit
    7. 3.7. Conclusion
  5. 4. Objects, Databases, and Applications
    1. 4.1. Beyond Flat Files
    2. 4.2. Object Serialization
      1. 4.2.1. Our Schema and Classes
      2. 4.2.2. Dumping Data
      3. 4.2.3. Storing and Retrieving Data
      4. 4.2.4. The Pruning Problem
      5. 4.2.5. Multilevel DBMs
      6. 4.2.6. Pixie
    3. 4.3. Object Databases
      1. 4.3.1. Object Database Pitfalls
      2. 4.3.2. Tangram
        1. 4.3.2.1. Tangram CRUD: create, read, update, delete
    4. 4.4. Database Abstraction
      1. 4.4.1. Trivial Mapping
      2. 4.4.2. Class::DBI
        1. 4.4.2.1. Relationships
        2. 4.4.2.2. Class::DBI extensions
      3. 4.4.3. Other Contenders
    5. 4.5. Practical Uses in Web Applications
      1. 4.5.1. Class::DBI and the Template Toolkit
      2. 4.5.2. Maypole
      3. 4.5.3. Other Application Frameworks
    6. 4.6. Conclusion
  6. 5. Natural Language Tools
    1. 5.1. Perl and Natural Languages
    2. 5.2. Handling English Text
      1. 5.2.1. Pluralizations and Inflections
      2. 5.2.2. Converting Words to Numbers
    3. 5.3. Modules for Parsing English
      1. 5.3.1. Splitting Up Text
      2. 5.3.2. Stemming and Stopwording
    4. 5.4. Categorization and Extraction
      1. 5.4.1. Bayesian Analysis
      2. 5.4.2. Keyword Extraction and Summary
        1. 5.4.2.1. Keyword extraction
      3. 5.4.3. Extracting Names and Places
    5. 5.5. Conclusion
  7. 6. Perl and Unicode
    1. 6.1. Terminology
    2. 6.2. What Is Unicode?
      1. 6.2.1. What Is UCS?
      2. 6.2.2. What is the Unicode Consortium?
      3. 6.2.3. Why Should I Care?
    3. 6.3. Unicode Transformation Formats
      1. 6.3.1. UCS-2
      2. 6.3.2. UTF-8
      3. 6.3.3. UTF-16BE
      4. 6.3.4. UTF-16LE
      5. 6.3.5. UCS-4
      6. 6.3.6. UTF-32
      7. 6.3.7. UTF-EBCDIC
      8. 6.3.8. UTF-7
    4. 6.4. Handling UTF-8 Data
      1. 6.4.1. Entering Unicode Characters
      2. 6.4.2. Unicode Regular Expressions
    5. 6.5. Encode
      1. 6.5.1. The PerlIO Trick
      2. 6.5.2. The Gory Details
    6. 6.6. Unicode for XS Authors
      1. 6.6.1. Traversing Strings
      2. 6.6.2. Encoding Strings
    7. 6.7. Conclusion
  8. 7. POE
    1. 7.1. Programming in an Event-Driven Environment
      1. 7.1.1. Hello, POE
      2. 7.1.2. Hello, Again, POE!
      3. 7.1.3. Wheels
      4. 7.1.4. A Port Forwarder
    2. 7.2. Top-Level Pieces: Components
      1. 7.2.1. Medium-Level Components
      2. 7.2.2. A POE Web Server
      3. 7.2.3. Highest-Level Components
    3. 7.3. Conclusion
  9. 8. Testing
    1. 8.1. Test::Simple
    2. 8.2. Test::More
      1. 8.2.1. Skips and Todos
      2. 8.2.2. Automated Tests
    3. 8.3. Test::Harness
    4. 8.4. Test::Builder
    5. 8.5. Test::Builder::Tester
    6. 8.6. Keeping Tests and Code Together
    7. 8.7. Unit Tests
      1. 8.7.1. Test::Class
      2. 8.7.2. Test::MockObject
      3. 8.7.3. Testing Apache, DBI, and Other Complex Environments
    8. 8.8. Conclusion
  10. 9. Inline Extensions
    1. 9.1. Simple Inline::C
      1. 9.1.1. Taking and Giving
      2. 9.1.2. C is not Always a Win
    2. 9.2. More Complex Tasks with Inline::C
      1. 9.2.1. Dealing with Perl’s Internal Values
      2. 9.2.2. Handling the Stack
      3. 9.2.3. Handling More Complex Perl Types
        1. 9.2.3.1. References
        2. 9.2.3.2. Arrays
        3. 9.2.3.3. Hashes
      4. 9.2.4. Wrapping C Libraries
      5. 9.2.5. Debugging Inline Extensions
      6. 9.2.6. Packaging Inline Modules
    3. 9.3. Inline:: Everything Else
      1. 9.3.1. Inline::Python
      2. 9.3.2. Inline::Ruby
      3. 9.3.3. Inline::CPR
      4. 9.3.4. Inline::Struct
      5. 9.3.5. Miscellaneous Other Inlines
    4. 9.4. Conclusion
  11. 10. Fun with Perl
    1. 10.1. Obfuscation
    2. 10.2. Just Another Perl Hacker
    3. 10.3. Perl Golf
    4. 10.4. Perl Poetry
    5. 10.5. Acme::*
    6. 10.6. Conclusion
  12. About the Author
  13. Colophon
  14. Copyright

Product information

  • Title: Advanced Perl Programming, 2nd Edition
  • Author(s): Simon Cozens
  • Release date: June 2005
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596004569