Perl Best Practices
By
Damian Conway
July 2005
Pages: 542
| Table of Contents
| Index
| Sample Chapter
Table of Contents
-
Chapter 1 Best Practices
-
Three Goals
-
This Book
-
Rehabiting
-
Chapter 2 Code Layout
-
Bracketing
-
Keywords
-
Subroutines and Variables
-
Builtins
-
Keys and Indices
-
Operators
-
Semicolons
-
Commas
-
Line Lengths
-
Indentation
-
Tabs
-
Blocks
-
Chunking
-
Elses
-
Vertical Alignment
-
Breaking Long Lines
-
Non-Terminal Expressions
-
Breaking by Precedence
-
Assignments
-
Ternaries
-
Lists
-
Automated Layout
-
Chapter 3 Naming Conventions
-
Identifiers
-
Booleans
-
Reference Variables
-
Arrays and Hashes
-
Underscores
-
Capitalization
-
Abbreviations
-
Ambiguous Abbreviations
-
Ambiguous Names
-
Utility Subroutines
-
Chapter 4 Values and Expressions
-
String Delimiters
-
Empty Strings
-
Single-Character Strings
-
Escaped Characters
-
Constants
-
Leading Zeros
-
Long Numbers
-
Multiline Strings
-
Here Documents
-
Heredoc Indentation
-
Heredoc Terminators
-
Heredoc Quoters
-
Barewords
-
Fat Commas
-
Thin Commas
-
Low-Precedence Operators
-
Lists
-
List Membership
-
Chapter 5 Variables
-
Lexical Variables
-
Package Variables
-
Localization
-
Initialization
-
Punctuation Variables
-
Localizing Punctuation Variables
-
Match Variables
-
Dollar-Underscore
-
Array Indices
-
Slicing
-
Slice Layout
-
Slice Factoring
-
Chapter 6 Control Structures
-
If Blocks
-
Postfix Selectors
-
Other Postfix Modifiers
-
Negative Control Statements
-
C-Style Loops
-
Unnecessary Subscripting
-
Necessary Subscripting
-
Iterator Variables
-
Non-Lexical Loop Iterators
-
List Generation
-
List Selections
-
List Transformation
-
Complex Mappings
-
List Processing Side Effects
-
Multipart Selections
-
Value Switches
-
Tabular Ternaries
-
do-while Loops
-
Linear Coding
-
Distributed Control
-
Redoing
-
Loop Labels
-
Chapter 7 Documentation
-
Types of Documentation
-
Boilerplates
-
Extended Boilerplates
-
Location
-
Contiguity
-
Position
-
Technical Documentation
-
Comments
-
Algorithmic Documentation
-
Elucidating Documentation
-
Defensive Documentation
-
Indicative Documentation
-
Discursive Documentation
-
Proofreading
-
Chapter 8 Built-in Functions
-
Sorting
-
Reversing Lists
-
Reversing Scalars
-
Fixed-Width Data
-
Separated Data
-
Variable-Width Data
-
String Evaluations
-
Automating Sorts
-
Substrings
-
Hash Values
-
Globbing
-
Sleeping
-
Mapping and Grepping
-
Utilities
-
Chapter 9 Subroutines
-
Call Syntax
-
Homonyms
-
Argument Lists
-
Named Arguments
-
Missing Arguments
-
Default Argument Values
-
Scalar Return Values
-
Contextual Return Values
-
Multi-Contextual Return Values
-
Prototypes
-
Implicit Returns
-
Returning Failure
-
Chapter 10 I/O
-
Filehandles
-
Indirect Filehandles
-
Localizing Filehandles
-
Opening Cleanly
-
Error Checking
-
Cleanup
-
Input Loops
-
Line-Based Input
-
Simple Slurping
-
Power Slurping
-
Standard Input
-
Printing to Filehandles
-
Simple Prompting
-
Interactivity
-
Power Prompting
-
Progress Indicators
-
Automatic Progress Indicators
-
Autoflushing
-
Chapter 11 References
-
Dereferencing
-
Braced References
-
Symbolic References
-
Cyclic References
-
Chapter 12 Regular Expressions
-
Extended Formatting
-
Line Boundaries
-
String Boundaries
-
End of String
-
Matching Anything
-
Lazy Flags
-
Brace Delimiters
-
Other Delimiters
-
Metacharacters
-
Named Characters
-
Properties
-
Whitespace
-
Unconstrained Repetitions
-
Capturing Parentheses
-
Captured Values
-
Capture Variables
-
Piecewise Matching
-
Tabular Regexes
-
Constructing Regexes
-
Canned Regexes
-
Alternations
-
Factoring Alternations
-
Backtracking
-
String Comparisons
-
Chapter 13 Error Handling
-
Exceptions
-
Builtin Failures
-
Contextual Failure
-
Systemic Failure
-
Recoverable Failure
-
Reporting Failure
-
Error Messages
-
Documenting Errors
-
OO Exceptions
-
Volatile Error Messages
-
Exception Hierarchies
-
Processing Exceptions
-
Exception Classes
-
Unpacking Exceptions
-
Chapter 14 Command-Line Processing
-
Command-Line Structure
-
Command-Line Conventions
-
Meta-options
-
In-situ Arguments
-
Command-Line Processing
-
Interface Consistency
-
Interapplication Consistency
-
Chapter 15 Objects
-
Using OO
-
Criteria
-
Pseudohashes
-
Restricted Hashes
-
Encapsulation
-
Constructors
-
Cloning
-
Destructors
-
Methods
-
Accessors
-
Lvalue Accessors
-
Indirect Objects
-
Class Interfaces
-
Operator Overloading
-
Coercions
-
Chapter 16 Class Hierarchies
-
Inheritance
-
Objects
-
Blessing Objects
-
Constructor Arguments
-
Base Class Initialization
-
Construction and Destruction
-
Automating Class Hierarchies
-
Attribute Demolition
-
Attribute Building
-
Coercions
-
Cumulative Methods
-
Autoloading
-
Chapter 17 Modules
-
Interfaces
-
Refactoring
-
Version Numbers
-
Version Requirements
-
Exporting
-
Declarative Exporting
-
Interface Variables
-
Creating Modules
-
The Standard Library
-
CPAN
-
Chapter 18 Testing and Debugging
-
Test Cases
-
Modular Testing
-
Test Suites
-
Failure
-
What to Test
-
Debugging and Testing
-
Strictures
-
Warnings
-
Correctness
-
Overriding Strictures
-
The Debugger
-
Manual Debugging
-
Semi-Automatic Debugging
-
Chapter 19 Miscellanea
-
Revision Control
-
Other Languages
-
Configuration Files
-
Formats
-
Ties
-
Cleverness
-
Encapsulated Cleverness
-
Benchmarking
-
Memory
-
Caching
-
Memoization
-
Caching for Optimization
-
Profiling
-
Enbugging
-
Appendix Essential Perl Best Practices
-
Appendix Perl Best Practices
-
, Code Layout
-
, Naming Conventions
-
, Values and Expressions
-
, Variables
-
, Control Structures
-
, Documentation
-
, Built-in Functions
-
, Subroutines
-
, I/O
-
, References
-
, Regular Expressions
-
, Error Handling
-
, Command-Line Processing
-
, Objects
-
, Class Hierarchies
-
, Modules
-
, Testing and Debugging
-
, Miscellanea
-
Appendix Editor Configurations
-
vim
-
vile
-
Emacs
-
BBEdit
-
TextWrangler
-
Appendix Recommended Modules and Utilities
-
Recommended Core Modules
-
Recommended CPAN Modules
-
Utility Subroutines
-
Appendix Bibliography
-
Perl Coding and Development Practices
-
General Coding and Development Practices
-
Colophon
Return to Perl Best Practices