Gift Guide

Perl Best Practices

( 3 )


Many programmers code by instinct, relying on convenient habits or a "style" they picked up early on. They aren't conscious of all the choices they make, like how they format their source, the names they use for variables, or the kinds of loops they use. They're focused entirely on problems they're solving, solutions they're creating, and algorithms they're implementing. So they write code in the way that seems natural, that happens intuitively, and that feels good.

But if ...

See more details below
$29.59 price
(Save 26%)$39.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (17) from $1.99   
  • New (8) from $21.71   
  • Used (9) from $1.99   
Perl Best Practices

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$17.99 price
(Save 43%)$31.99 List Price


Many programmers code by instinct, relying on convenient habits or a "style" they picked up early on. They aren't conscious of all the choices they make, like how they format their source, the names they use for variables, or the kinds of loops they use. They're focused entirely on problems they're solving, solutions they're creating, and algorithms they're implementing. So they write code in the way that seems natural, that happens intuitively, and that feels good.

But if you're serious about your profession, intuition isn't enough. Perl Best Practices author Damian Conway explains that rules, conventions, standards, and practices not only help programmers communicate and coordinate with one another, they also provide a reliable framework for thinking about problems, and a common language for expressing solutions. This is especially critical in Perl, because the language is designed to offer many ways to accomplish the same task, and consequently it supports many incompatible dialects.

With a good dose of Aussie humor, Dr. Conway (familiar to many in the Perl community) offers 256 guidelines on the art of coding to help you write better Perl code—in fact, the best Perl code you possibly can. The guidelines cover code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging.

They're designed to work together to produce code that is clear, robust, efficient, maintainable, and concise, but Dr. Conway doesn't pretend that this is the one true universal and unequivocal set of best practices. Instead, Perl Best Practices offers coherent and widely applicable suggestions based on real-world experience of how code is actually written, rather than on someone's ivory-tower theories on howsoftware ought to be created.

Most of all, Perl Best Practices offers guidelines that actually work, and that many developers around the world are already using. Much like Perl itself, these guidelines are about helping you to get your job done, without getting in the way.

Praise for Perl Best Practices from Perl community members:

"As a manager of a large Perl project, I'd ensure that every member of my team has a copy of Perl Best Practices on their desk, and use it as the basis for an in-house style guide."— Randal Schwartz

"There are no more excuses for writing bad Perl programs. All levels of Perl programmer will be more productive after reading this book."— Peter Scott

"Perl Best Practices will be the next big important book in the evolution of Perl. The ideas and practices Damian lays down will help bring Perl out from under the embarrassing heading of "scripting languages". Many of us have known Perl is a real programming language, worthy of all the tasks normally delegated to Java and C++. With Perl Best Practices, Damian shows specifically how and why, so everyone else can see, too."— Andy Lester

"Damian's done what many thought impossible: show how to build large, maintainable Perl applications, while still letting Perl be the powerful, expressive language that programmers have loved for years."— Bill Odom

"Finally, a means to bring lasting order to the process and product of real Perl development teams."— Andrew Sundstrom

"Perl Best Practices provides a valuable education in how to write robust, maintainable Perl, and is a definitive citation source when coaching other programmers."— Bennett Todd"I've been teaching Perl for years, and find the same question keeps being asked: Where can I find a reference for writing reusable, maintainable Perl code? Finally I have a decent answer."— Paul Fenwick"At last a well researched, well thought-out, comprehensive guide to Perl style. Instead of each of us developing our own, we can learn good practices from one of Perl's most prolific and experienced authors. I recommend this book to anyone who prefers getting on with the job rather than going back and fixing errors caused by syntax and poor style issues."— Jacinta Richardson"If you care about programming in any language read this book. Even if you don't intend to follow all of the practices, thinking through your style will improve it."— Steven Lembark"The Perl community's best author is back with another outstanding book. There has never been a comprehensive reference on high quality Perl coding and style until Perl Best Practices. This book fills a large gap in every Perl bookshelf."— Uri Guttman

Read More Show Less

Product Details

  • ISBN-13: 9780596001735
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 7/3/2005
  • Edition number: 1
  • Pages: 544
  • Sales rank: 782,512
  • Product dimensions: 7.00 (w) x 9.19 (h) x 0.98 (d)

Meet the Author

Damian Conway holds a PhD in Computer Science and is an honorary Associate Professor with the School of Computer Science and Software Engineering at Monash University, Melbourne, Australia.Currently he runs an international IT training company—Thoughtstream—which provides programmer development from beginner to masterclass level throughout Europe, North America, and Australasia.Damian was the winner of the 1998, 1999, and 2000 Larry Wall Awards for Practical Utility. The best technical paper at the annual Perl Conference was subsequently named in his honour. He is a member of the technical committee for The Perl Conference, a keynote speaker at many Open Source conferences, a former columnist for The Perl Journal, and author of the book Object Oriented Perl. In 2001 Damian received the first "Perl Foundation Development Grant" and spent 20 months working on projects for the betterment of Perl.A popular speaker and trainer, he is also the author of numerous well-known Perl modules, including Parse::RecDescent (a sophisticated parsing tool), Class::Contract (design-by-contract programming in Perl), Lingua::EN::Inflect (rule-based English transformations for text generation), Class::Multimethods (multiple dispatch polymorphism), Text::Autoformat (intelligent automatic reformatting of plaintext), Switch (Perl's missing case statement), NEXT (resumptive method dispatch), Filter::Simple (Perl-based source code manipulation), Quantum::Superpositions (auto-parallelization of serial code using a quantum mechanical metaphor), and Lingua::Romana::Perligata (programming in Latin).Most of his time is now spent working with Larry Wall on the design of the new Perl 6 programming language.

Read More Show Less

Table of Contents

Contents of This Book;
Conventions Used in This Book;
Code Examples;
Chapter 1: Best Practices;
1.1 Three Goals;
1.2 This Book;
1.3 Rehabiting;
Chapter 2: Code Layout;
2.1 Bracketing;
2.2 Keywords;
2.3 Subroutines and Variables;
2.4 Builtins;
2.5 Keys and Indices;
2.6 Operators;
2.7 Semicolons;
2.8 Commas;
2.9 Line Lengths;
2.10 Indentation;
2.11 Tabs;
2.12 Blocks;
2.13 Chunking;
2.14 Elses;
2.15 Vertical Alignment;
2.16 Breaking Long Lines;
2.17 Non-Terminal Expressions;
2.18 Breaking by Precedence;
2.19 Assignments;
2.20 Ternaries;
2.21 Lists;
2.22 Automated Layout;
Chapter 3: Naming Conventions;
3.1 Identifiers;
3.2 Booleans;
3.3 Reference Variables;
3.4 Arrays and Hashes;
3.5 Underscores;
3.6 Capitalization;
3.7 Abbreviations;
3.8 Ambiguous Abbreviations;
3.9 Ambiguous Names;
3.10 Utility Subroutines;
Chapter 4: Values and Expressions;
4.1 String Delimiters;
4.2 Empty Strings;
4.3 Single-Character Strings;
4.4 Escaped Characters;
4.5 Constants;
4.6 Leading Zeros;
4.7 Long Numbers;
4.8 Multiline Strings;
4.9 Here Documents;
4.10 Heredoc Indentation;
4.11 Heredoc Terminators;
4.12 Heredoc Quoters;
4.13 Barewords;
4.14 Fat Commas;
4.15 Thin Commas;
4.16 Low-Precedence Operators;
4.17 Lists;
4.18 List Membership;
Chapter 5: Variables;
5.1 Lexical Variables;
5.2 Package Variables;
5.3 Localization;
5.4 Initialization;
5.5 Punctuation Variables;
5.6 Localizing Punctuation Variables;
5.7 Match Variables;
5.8 Dollar-Underscore;
5.9 Array Indices;
5.10 Slicing;
5.11 Slice Layout;
5.12 Slice Factoring;
Chapter 6: Control Structures;
6.1 If Blocks;
6.2 Postfix Selectors;
6.3 Other Postfix Modifiers;
6.4 Negative Control Statements;
6.5 C-Style Loops;
6.6 Unnecessary Subscripting;
6.7 Necessary Subscripting;
6.8 Iterator Variables;
6.9 Non-Lexical Loop Iterators;
6.10 List Generation;
6.11 List Selections;
6.12 List Transformation;
6.13 Complex Mappings;
6.14 List Processing Side Effects;
6.15 Multipart Selections;
6.16 Value Switches;
6.17 Tabular Ternaries;
6.18 do-while Loops;
6.19 Linear Coding;
6.20 Distributed Control;
6.21 Redoing;
6.22 Loop Labels;
Chapter 7: Documentation;
7.1 Types of Documentation;
7.2 Boilerplates;
7.3 Extended Boilerplates;
7.4 Location;
7.5 Contiguity;
7.6 Position;
7.7 Technical Documentation;
7.9 Algorithmic Documentation;
7.10 Elucidating Documentation;
7.11 Defensive Documentation;
7.12 Indicative Documentation;
7.13 Discursive Documentation;
7.14 Proofreading;
Chapter 8: Built-in Functions;
8.1 Sorting;
8.2 Reversing Lists;
8.3 Reversing Scalars;
8.4 Fixed-Width Data;
8.5 Separated Data;
8.6 Variable-Width Data;
8.7 String Evaluations;
8.8 Automating Sorts;
8.9 Substrings;
8.10 Hash Values;
8.11 Globbing;
8.12 Sleeping;
8.13 Mapping and Grepping;
8.14 Utilities;
Chapter 9: Subroutines;
9.1 Call Syntax;
9.2 Homonyms;
9.3 Argument Lists;
9.4 Named Arguments;
9.5 Missing Arguments;
9.6 Default Argument Values;
9.7 Scalar Return Values;
9.8 Contextual Return Values;
9.9 Multi-Contextual Return Values;
9.10 Prototypes;
9.11 Implicit Returns;
9.12 Returning Failure;
Chapter 10: I/O;
10.1 Filehandles;
10.2 Indirect Filehandles;
10.3 Localizing Filehandles;
10.4 Opening Cleanly;
10.5 Error Checking;
10.6 Cleanup;
10.7 Input Loops;
10.8 Line-Based Input;
10.9 Simple Slurping;
10.10 Power Slurping;
10.11 Standard Input;
10.12 Printing to Filehandles;
10.13 Simple Prompting;
10.14 Interactivity;
10.15 Power Prompting;
10.16 Progress Indicators;
10.17 Automatic Progress Indicators;
10.18 Autoflushing;
Chapter 11: References;
11.1 Dereferencing;
11.2 Braced References;
11.3 Symbolic References;
11.4 Cyclic References;
Chapter 12: Regular Expressions;
12.1 Extended Formatting;
12.2 Line Boundaries;
12.3 String Boundaries;
12.4 End of String;
12.5 Matching Anything;
12.6 Lazy Flags;
12.7 Brace Delimiters;
12.8 Other Delimiters;
12.9 Metacharacters;
12.10 Named Characters;
12.11 Properties;
12.12 Whitespace;
12.13 Unconstrained Repetitions;
12.14 Capturing Parentheses;
12.15 Captured Values;
12.16 Capture Variables;
12.17 Piecewise Matching;
12.18 Tabular Regexes;
12.19 Constructing Regexes;
12.20 Canned Regexes;
12.21 Alternations;
12.22 Factoring Alternations;
12.23 Backtracking;
12.24 String Comparisons;
Chapter 13: Error Handling;
13.1 Exceptions;
13.2 Builtin Failures;
13.3 Contextual Failure;
13.4 Systemic Failure;
13.5 Recoverable Failure;
13.6 Reporting Failure;
13.7 Error Messages;
13.8 Documenting Errors;
13.9 OO Exceptions;
13.10 Volatile Error Messages;
13.11 Exception Hierarchies;
13.12 Processing Exceptions;
13.13 Exception Classes;
13.14 Unpacking Exceptions;
Chapter 14: Command-Line Processing;
14.1 Command-Line Structure;
14.2 Command-Line Conventions;
14.3 Meta-options;
14.4 In-situ Arguments;
14.5 Command-Line Processing;
14.6 Interface Consistency;
14.7 Interapplication Consistency;
Chapter 15: Objects;
15.1 Using OO;
15.2 Criteria;
15.3 Pseudohashes;
15.4 Restricted Hashes;
15.5 Encapsulation;
15.6 Constructors;
15.7 Cloning;
15.8 Destructors;
15.9 Methods;
15.10 Accessors;
15.11 Lvalue Accessors;
15.12 Indirect Objects;
15.13 Class Interfaces;
15.14 Operator Overloading;
15.15 Coercions;
Chapter 16: Class Hierarchies;
16.1 Inheritance;
16.2 Objects;
16.3 Blessing Objects;
16.4 Constructor Arguments;
16.5 Base Class Initialization;
16.6 Construction and Destruction;
16.7 Automating Class Hierarchies;
16.8 Attribute Demolition;
16.9 Attribute Building;
16.10 Coercions;
16.11 Cumulative Methods;
16.12 Autoloading;
Chapter 17: Modules;
17.1 Interfaces;
17.2 Refactoring;
17.3 Version Numbers;
17.4 Version Requirements;
17.5 Exporting;
17.6 Declarative Exporting;
17.7 Interface Variables;
17.8 Creating Modules;
17.9 The Standard Library;
17.10 CPAN;
Chapter 18: Testing and Debugging;
18.1 Test Cases;
18.2 Modular Testing;
18.3 Test Suites;
18.4 Failure;
18.5 What to Test;
18.6 Debugging and Testing;
18.7 Strictures;
18.8 Warnings;
18.9 Correctness;
18.10 Overriding Strictures;
18.11 The Debugger;
18.12 Manual Debugging;
18.13 Semi-Automatic Debugging;
Chapter 19: Miscellanea;
19.1 Revision Control;
19.2 Other Languages;
19.3 Configuration Files;
19.4 Formats;
19.5 Ties;
19.6 Cleverness;
19.7 Encapsulated Cleverness;
19.8 Benchmarking;
19.9 Memory;
19.10 Caching;
19.11 Memoization;
19.12 Caching for Optimization;
19.13 Profiling;
19.14 Enbugging;
Essential Perl Best Practices;
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;
Editor Configurations;
Recommended Modules and Utilities;
Recommended Core Modules;
Recommended CPAN Modules;
Utility Subroutines;
Perl Coding and Development Practices;
General Coding and Development Practices;

Read More Show Less

Customer Reviews

Average Rating 3.5
( 3 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 3 Customer Reviews
  • Anonymous

    Posted September 4, 2005


    It's almost a certainty that you won't like all of the suggestions that follow if you're an experienced developer. Author Damian Conway has done an outstanding job of designing a book to help you write better Perl code. Conway begins by explaining why it might be worth reassessing your current coding practices. Next, the author tackles the many contentious issues of code layout. Then, he presents a series of guidelines that can help you choose more descriptive name for variables, subroutines, and namespaces. Conway continues by providing a simple set of rules that can help you avoid common pitfalls when creating character strings, numbers, and lists. In addition, the author next explores a robust approach to using variables. He also examines Perl's rich variety of control structures, encouraging the use of those that are easier to maintain, less error-prone, or more efficient. The author next suggests a series of techniques that can make documenting your code less tedious, and therefore more likely. Next, the author discusses better ways of using some of Perl's most popular built-in functions, including sort, reveres, scalar, eval, unpack, split, substr, values, select, sleep, map and grep. Conway continues by describing efficient and maintainable ways to write subroutines in Perl, including the use of positional, named, and optional arguments argument validation and defaults safe calling and return conventions predictable return values in various contexts and, why subroutine prototypes and implicit returns should be avoided. Next, he explains how to open and close files reliably when to use line-based input, how to correctly detect interactive applications the importance of prompting and, how best to provide feedback to users during long non-interactive tasks. Then, he offers advice on demystifying Perl's many dereferencing syn-taxes discusses why symbolic references create more problems than they solve and, recommends ways to prevent cyclic reference chains from causing memory leaks. The author next presents guidelines for using regular expressions. Then, he advocates a coherent exception-based approach to error handling, and explains why exceptions are preferable to special return values or flags. Next, he addresses the design and implementation of command-line interfaces, both for individual programs and for application suites. Conway continues by offering a robust and efficient approach to creating objects and class hierarchies in Perl. Next, he looks at non-object-oriented modules exploring the best ways to create them design their interfaces declare and check their version numbers and, refacter existing code into them. Then, he encourages the use of testing, advocating test-driven design and development using the core Test:: modules. Finally, he offers several additional guidelines on miscellaneous topics such as revision control interfacing to code written in other languages processing configuration files text formatting tied variables benchmarking and profiling your code caching techniques and, some general advice on refactoring. With the preceding in mind, the author has done an excellent job of designing a book that produces Perl code that is clear, robust, efficient, maintainable, and concise. At the end of the day, the guidelines in this book, much like Perl itself, are about helping you get your job done, without getting in the way.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted November 30, 2012

    No text was provided for this review.

  • Anonymous

    Posted June 24, 2011

    No text was provided for this review.

Sort by: Showing all of 3 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)