Computer Science & Perl Programming
Best of The Perl Journal
By
O'Reilly Media, Inc.
Edited by
Jon Orwant
November 2002
Pages: 758
| Table of Contents
| Sample Chapter
| Colophon
Table of Contents
-
Chapter 1 Introduction
-
History of TPJ
-
Computer Science and Perl Programming
-
Beginner Concepts
-
Chapter 2 All About Arrays
- Basics
- Positions
- Position Versus Count
- Foreach Loops
- The Reverse and Sort Functions
- Slices
- Adding and Deleting Values
- Lists to Strings and Back Again
- Putting It All Together
-
Chapter 3 Perfect Programming
- Warnings with -w
- The strict Pragma
- Tainting and Safe
- Checking Return Values
- Planning for Failure
- The Perl Debugger
- The Perl Profiler
- Stack Traces
-
Chapter 4 Precedence
- What Is Precedence?
- Rules and More Rules
- An Explosion of Rules
- Precedence Traps and Surprises
- List Operators and Unary Operators
- Complete Rules of Precedence
- How to Remember All the Rules
- Quiz
- Answers
-
Chapter 5 The Birth of a One-Liner
-
Chapter 6 Comparators, Sorting, and Hashes
- Sorting
- Sorting Hashes
- Efficient Sorting
- Further Reading
-
Chapter 7 What Is Truth?
- The undef Function
- Back to Truth
- Truth in Context
- Applications
- Conclusion
-
Chapter 8 Using Object-Oriented Modules
- Modules and Their Functional Interfaces
- Modules with Object-Oriented Interfaces
- What Can You Do with Objects?
- What's in an Object?
- What Is an Object Value?
- So Why Do Some Modules Use Objects?
-
Chapter 9 Unreal Numbers
- A Surprising Program
- The Right Way
-
Chapter 10 CryptoContext
- Context
- Prototypes
- Subroutine Calls
- Putting Them All Together
- Conclusion
-
Chapter 11 References
- Who Needs Complicated Data Structures?
- The Solution
- Making References
- Using References
- An Example
- Solution
- The Rest
- In Summary
-
Chapter 12 Perl Heresies
- Don't Use -w
- Don't Use Regular Expressions Just Because They're Cool
- Don't Always Use Modules
- Partial Solutions Are Okay
-
Regular Expressions
-
Chapter 13 Understanding Regular Expressions, Part I
- The Story of Fred
- Reality Check
- Regular Expression Background
- Perl Regex Engine Basics
- The First Real Rule of Regexes
- A Single Match Attempt
- Options, Options, Options
- How the Path Is Chosen
- That's Pretty Much It
-
Chapter 14 Understanding Regular Expressions, Part II
- Knowing Versus Knowing on Paper
- Efficiency
- Benchmarking
- Conclusion
-
Chapter 15 Understanding Regular Expressions, Part III
-
Chapter 16 Nibbling Strings
- The Problem
- Going on a Diet
-
Chapter 17 How Regexes Work
- Machines
- Blank Arrows
- Rules Again
- How to Turn a Regex into a Penny Machine
- What Do You Mean, Done?
- The Regex Module
- Implications for Perl
- What About Backreferences?
- Internals of Regex.pm
- Lies
- Other Directions
- Bibliography
-
Computer Science
-
Chapter 18 Infinite Lists
- Hamming's Problem
- Streams
- Hamming's Problem Revisited
- Dataflow Programming
- Other Directions
- References
-
Chapter 19 Compression
- Morse Code
- Ambiguous Codes
- Huffman Coding
- The Code
- The Rub
- Another Rub
- Other Methods
- Other Directions
- Bibliography
-
Chapter 20 Memoization
- Recursive Functions
- The Memoize Module
- Module Internals
- Some Other Applications of Memoization
- When Memoizing Doesn't Work
- Bibliography
-
Chapter 21 Parsing
- A Sample Parse
- Formal Grammars
- The Different Types of Parsers
- Building a Parser with Parse::RecDescent
- How Parse::RecDescent Works
- An In-Depth Example
- Advanced Features of Parse::RecDescent
- Practical Applications of Parsing
- Limitations of Parse::Recdescent
- More Information
- Acknowledgments
-
Chapter 22 Trees and Game Trees
- What Is a Tree?
- Formal Definition
- Markup Language Trees
- Building Your Own Trees
- An Implementation: Game Trees for Alak
- References
-
Chapter 23 B_Trees
- A Review of Binary Trees
- The Problem with Binary Trees
- B-Trees Are Always Balanced
- A Guided Tour of the Program
- Moving Down
- Moving Up
- Details
- Other Directions
- Bibliography
-
Chapter 24 Making Life and Death Decisions with Perl
- Probability Theory
- Whoa!
- Perl
- Last Words
-
Chapter 25 Information Retrieval
- Text Searches on Manual Pages
- The Implementation
- Relevance Feedback
- "Advanced" Search Operators
- Conclusion
- References
-
Chapter 26 Randomness
- Congruential Generators
- Choosing the Seed
- LFSRs
- References
-
Chapter 27 Random Number Generators and XS
- Random Versus Pseudorandom Numbers
- Linear Congruential Generators Revisited
- A Better Generator for Perl
- Bridging C and Perl with XS
- Acknowledgments
- References
-
Programming Techniques
-
Chapter 28 Suffering from Buffering
- What Is Buffering?
- Surprise!
- Disabling Inappropriate Buffering
- Hot and Not Hot
- Other Perils of Buffering
- Flushing on Command
- Other Directions
- Summary
-
Chapter 29 Scoping
- Package Variables
- The Current Package
- Package Variable Trivia
- Lexical Variables
- local and my
- What Good Is local?
- When to Use my and When to Use local
- Other Properties of my Variables
- my Variable Trivia
- Declarations
- Summary
-
Chapter 30 Seven Useful Uses of local
- 1. Special Variables
- 2. Localized Filehandles
- 3. The First Class Filehandle Trick
- 4. Aliases
- 5. Dynamic Scope
- 6. Dynamic Scope Revisited
- 7. Perl 4 and Other Relics
- Summary
-
Chapter 31 Parsing Command-Line Options
- Option Parsing Conventions
- The Simplest Way
- The Easy Way
- The Advanced Way
- Other Option Handling Modules
-
Chapter 32 Building a Better Hash with tie
- Introduction
- The Problem
- Discussion
- Attempted Solutions
- A Working Data Structure
- Implementation
- Implementing a Tied Hash
- Using a Tied Hash
- Testing
- Optimizations
- Making It a Module
- Summing Up
- References
-
Chapter 33 Source Filters
- Concepts
- Using Filters
- Writing a Source Filter
- The Debug Filter
- Conclusion
-
Chapter 34 Overloading
- Defining Your Own Types
- Adding Methods to the Date Class
- A Minor Problem
- Introducing Overloading
- Overloading More Methods
- Overloading and Associativity
- Full Overloading Implementations
- Automatically Generating Overloaded Methods
- The Fallback Mechanism
- Overloading and Inheritance
- Limitations of Operator Overloading
- Conclusion
- References
-
Chapter 35 Building Objects Out of Arrays
- OO Basics
- Arrays Are Faster
- Arrays Use Less Space
- Arrays Can Prevent Attribute Collisions
- Arrays Can Prevent Misspellings
- Disadvantages
- Other Approaches
-
Chapter 36 Hiding Objects with Closures
- A Simple Example
- Closures
- What About Inheritance?
- Conclusion
-
Chapter 37 Multiple Dispatch in Perl
- Multiple Dispatch
- Multiple Dispatch via "Tests-in-Methods"
- Multiple Dispatch via a Table
- Comparing the Two Approaches
- Dynamic Dispatch Tables
- The Class::Multimethods Module
-
Software Development
-
Chapter 38 Using Other Languages from Perl
- Introducing Inline.pm
- A More Complex Example
- Calling C Functions from Perl
- Manipulating Perl's Stack
- How Inline Works
- Creating Perl Extensions
- Inline::Config
- XS and SWIG
- Using Perl as C's Memory Manager
- Benchmarks
-
Chapter 39 SWIG
- Hooks by Hand
- Wrapping a C Function
- Interface Files
- An In-Depth Example: Emulating top
- The top Emulator
- Conclusion
-
Chapter 40 Benchmarking
- The Trouble with time( )
- Better Resolution with times
- The Benchmark Module
- Example: Summing an Array
- Conclusion
-
Chapter 41 Building Software with Cons
- Make Doesn't Do the Right Thing
- The Solution: Cons
- Summary
-
Chapter 42 MakeMaker
- Reasons to Use MakeMaker
- h2xs
- Components of Makefile.PL
- A Deeper Example
- Advanced Makefile Features
- MakeMaker and Installation of Modules
- perllocal.pod
-
Chapter 43 Autoloading Perl Code
- Why Autoload?
- Using the AutoLoader
- How Autoloading Works
- AutoSplitting Your Module
- AutoLoading Scripts
- AutoLoading C Programs
- Summary
-
Chapter 44 Debugging and Devel::
- Runtime Examination of Data
- Profiling and Coverage Testing
- Reference Manipulation
- Helping C and C++ Programmers
- Rolling Your Own
- Which Should You Use?
-
Networking
-
Chapter 45 Email with Attachments
- What Is MIME, and Why Do I Care?
- How Does MIME Encode Data?
- Multiple Pieces of MIME
- How to Create a Mime Message
- An Alternate Route
- A Full-Blown Example
- Conclusion
-
Chapter 46 Sending Mail Without sendmail
- Some Email Background
- The Mail Itself
- Sending Mail in Six Easy Steps
- What Next?
-
Chapter 47 Filtering Mail
- What Is It?
- A Very Simple Mail Filter
- Separating Mail into Folders
- Mail and News
- A Complete Filter
- Caveats
- Conclusion
-
Chapter 48 Net::Telnet
- The Problem
- The Solution
- Telnetting the Hard Way
- Telnetting the Easy Way
- Telnetting the Easiest Way
- Special Considerations
- Other Features
-
Chapter 49 Microsoft Office
- Background
- The Problem
- The Solution
- Wait, There's More
-
Chapter 50 Client-Server Applications
- Using the inetd Super-Daemon
- A Standalone Server
- A Threaded Server
- Launching Standalone Servers from inetd
- Further Information
-
Chapter 51 Managing Streaming Audio
- Playlists, Streams, and ID3 Tags
- Apache::MP3
- Conclusion
-
Chapter 52 A 74-Line Ip Telephone
- Sound Cards and /dev/dsp
- The Simple Version
- Adding an MP3 Encoder
- Summary
- References
-
Chapter 53 Controlling Modems
- Initializing Your Modem
- Getting Your Modem to Dial
- To Block or Not to Block?
- What's Next?
- Afterword
- References
-
Chapter 54 Using Usenet from Perl
- Finding Newsgroups
- Retrieving Articles
- Posting Articles
-
Chapter 55 Transferring Files with FTP
- A Simple Example
- Multiple FTP Connections
- Transferring Files Between Servers
-
Chapter 56 Spidering an FTP Site
- Motivation
- Net::FTP
- Downloading a File (the Simple Case)
- Recursion
- Downloading a File Tree (the Recursive Case)
- Uploading a File (the Simple Case)
- Uploading a File Tree (the Recursive Case)
- Applications
-
Chapter 57 DNS Updates with Perl
- DNS Basics
- DNS Servers
- Dynamic Update
- Setting Up Your Nameserver
- Delegating the Zone
- Using Net::DNS::Update
- Paths for Futher Exploration
-
Databases
-
Chapter 58 DBI
- The Architecture of DBI
- Why DBI?
- The Modules
- Handles
- Resources
- Sample Code
-
Chapter 59 Using DBI with Microsoft Access
- The Win32-Access-ODBC-DBI::DBD Checklist:
- References
-
Chapter 60 DBI Caveats
- DBI and Loops
- Placeholders
- Fetches
- Bind Columns
- Error Checking
- Transactions
- References
-
Chapter 61 Beyond Hardcoded Database Applications with DBIx::Recordset
- CRUD Without SQL
- Sample Usage
- A DBI Version
- Conclusion
-
Chapter 62 Win32::ODBC
- Win32::ODBC Basics
- Demystifying SQL
- Installing Win32::ODBC
- Getting Started
- Debugging
- CRUD
- Transactions
- Data Sources
- Data Dictionary
- Conclusion
-
Chapter 63 Net::LDAP
- What Is LDAP?
- Setting Up an OpenLDAP Server
- Loading Data into the Directory
- A Searchable Web Interface to Manage Your Directory
- Where LDAP Is Going
- References
-
Chapter 64 Web Databases the Genome Project Way
- The ACEDB Database
- ACEDB Objects and Classes
- Accessing ACEDB from Perl
- ACEDB Meets the Web
- Registering ACEDB Displays
- Conclusions
- References
-
Chapter 65 Spreadsheet::WriteExcel
- Using Spreadsheet::WriteExcel
- How the Spreadsheet::WriteExcel Module Works
- Alternative Ways of Writing to Excel
- Reading from Excel
- Win32::OLE
- Obtaining Spreadsheet::WriteExcel
- References
-
Internals
-
Chapter 66 How to Improve Perl
-
Chapter 67 Components of the Perl Distribution
- The Components of Perl
- Summary
-
Chapter 68 Basic Perl Anatomy
- How Perl Works
- Lexical Analysis
- Parsing
- Compilation
- Execution
- Perl Subsystems
- For Further Reading
-
Chapter 69 Lexical Analysis
- Tokenizing
- Perl's Lexer
- Lexer Variables
- Tokenizing Considerations
- Further Information
-
Chapter 70 Debugging Perl Programs with -D
- What -D Does for You
- Trace Execution with -Dt
- Stack Snapshots with -Ds
- Syntax Tree Dump with -Dx
- Regular Expression Parsing and Execution with -Dr
- Method and Overloading Resolution with -Do
- Context (Loop) Stack Processing with -Dl
- Tokenizing and Parsing with -Dp
- Other -D Debugging Flags
-
Chapter 71 Microperl
- Bootstrapping
- Building Microperl
- How Microperl Works
- Practical Uses for Microperl
- Problems
- Future Work
-
Colophon
Return to Computer Science & Perl Programming