OReilly perl best practices jul 2005 ISBN 0596001738

1.1K 116 0
OReilly perl best practices jul 2005 ISBN 0596001738

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Perl Best Practices By Damian Conway Publisher: O'Reilly Pub Date: July 2005 ISBN: 0-596-00173-8 Pages: 542 Table of Contents | Index 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 how software 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 Perl Best Practices By Damian Conway Publisher: O'Reilly Pub Date: July 2005 ISBN: 0-596-00173-8 Pages: 542 Table of Contents | Index Copyright Dedication Preface Contents of This Book Conventions Used in This Book Code Examples Feedback Acknowledgments Chapter 1 Best Practices Section 1.1 Three Goals Section 1.2 This Book Section 1.3 Rehabiting Chapter 2 Code Layout Section 2.1 Bracketing Section 2.2 Keywords Section 2.3 Subroutines and Variables Section 2.4 Builtins Section 2.5 Keys and Indices Section 2.6 Operators Section 2.7 Semicolons Section 2.8 Commas Section 2.9 Line Lengths Section 2.10 Indentation Section 2.11 Tabs Section 2.12 Blocks Section 2.13 Chunking Section 2.14 Elses Section 2.15 Vertical Alignment Section 2.16 Breaking Long Lines Section 2.17 Non-Terminal Expressions Section 2.18 Breaking by Precedence Section 2.19 Assignments Section 2.20 Ternaries Section 2.21 Lists Section 2.22 Automated Layout Chapter 3 Naming Conventions Section 3.1 Identifiers Section 3.2 Booleans Section 3.3 Reference Variables Section 3.4 Arrays and Hashes Section 3.5 Underscores Section 3.6 Capitalization Section 3.7 Abbreviations Section 3.8 Ambiguous Abbreviations Section 3.9 Ambiguous Names Section 3.10 Utility Subroutines Chapter 4 Values and Expressions Section 4.1 String Delimiters Section 4.2 Empty Strings Section 4.3 Single-Character Strings Section 4.4 Escaped Characters Section 4.5 Constants Section 4.6 Leading Zeros Section 4.7 Long Numbers Section 4.8 Multiline Strings Section 4.9 Here Documents Section 4.10 Heredoc Indentation Section 4.11 Heredoc Terminators Section 4.12 Heredoc Quoters Section 4.13 Barewords Section 4.14 Fat Commas Section 4.15 Thin Commas Section 4.16 Low-Precedence Operators Section 4.17 Lists Section 4.18 List Membership Chapter 5 Variables Section 5.1 Lexical Variables Section 5.2 Package Variables Section 5.3 Localization Section 5.4 Initialization Section 5.5 Punctuation Variables Section 5.6 Localizing Punctuation Variables Section 5.7 Match Variables Section 5.8 Dollar-Underscore Section 5.9 Array Indices Section 5.10 Slicing Section 5.11 Slice Layout Section 5.12 Slice Factoring Chapter 6 Control Structures Section 6.1 If Blocks Section 6.2 Postfix Selectors Section 6.3 Other Postfix Modifiers Section 6.4 Negative Control Statements Section 6.5 C-Style Loops Section 6.6 Unnecessary Subscripting Section 6.7 Necessary Subscripting Section 6.8 Iterator Variables Section 6.9 Non-Lexical Loop Iterators Section 6.10 List Generation Section 6.11 List Selections Section 6.12 List Transformation Section 6.13 Complex Mappings Section 6.14 List Processing Side Effects Section 6.15 Multipart Selections Section 6.16 Value Switches Section 6.17 Tabular Ternaries Section 6.18 do-while Loops Section 6.19 Linear Coding Section 6.20 Distributed Control Section 6.21 Redoing Section 6.22 Loop Labels Chapter 7 Documentation Section 7.1 Types of Documentation Section 7.2 Boilerplates Section 7.3 Extended Boilerplates Section 7.4 Location Section 7.5 Contiguity Section 7.6 Position Section 7.7 Technical Documentation Section 7.8 Comments Section 7.9 Algorithmic Documentation Section 7.10 Elucidating Documentation Section 7.11 Defensive Documentation Section 7.12 Indicative Documentation Section 7.13 Discursive Documentation Section 7.14 Proofreading Chapter 8 Built-in Functions Section 8.1 Sorting Section 8.2 Reversing Lists Section 8.3 Reversing Scalars Section 8.4 Fixed-Width Data Section 8.5 Separated Data Section 8.6 Variable-Width Data Section 8.7 String Evaluations Section 8.8 Automating Sorts Section 8.9 Substrings Section 8.10 Hash Values Section 8.11 Globbing Section 8.12 Sleeping Section 8.13 Mapping and Grepping Section 8.14 Utilities Chapter 9 Subroutines Section 9.1 Call Syntax Section 9.2 Homonyms Section 9.3 Argument Lists Section 9.4 Named Arguments Section 9.5 Missing Arguments Section 9.6 Default Argument Values Section 9.7 Scalar Return Values Section 9.8 Contextual Return Values Section 9.9 Multi-Contextual Return Values Section 9.10 Prototypes Section 9.11 Implicit Returns Section 9.12 Returning Failure Chapter 10 I/O Section 10.1 Filehandles Section 10.2 Indirect Filehandles Section 10.3 Localizing Filehandles Section 10.4 Opening Cleanly Section 10.5 Error Checking Section 10.6 Cleanup Section 10.7 Input Loops Section 10.8 Line-Based Input Section 10.9 Simple Slurping Section 10.10 Power Slurping Section 10.11 Standard Input Section 10.12 Printing to Filehandles Section 10.13 Simple Prompting Section 10.14 Interactivity Section 10.15 Power Prompting Section 10.16 Progress Indicators Section 10.17 Automatic Progress Indicators Section 10.18 Autoflushing Chapter 11 References Section 11.1 Dereferencing Section 11.2 Braced References Section 11.3 Symbolic References Section 11.4 Cyclic References Chapter 12 Regular Expressions Section 12.1 Extended Formatting Section 12.2 Line Boundaries Section 12.3 String Boundaries Section 12.4 End of String Section 12.5 Matching Anything Section 12.6 Lazy Flags Section 12.7 Brace Delimiters Section 12.8 Other Delimiters Section 12.9 Metacharacters Section 12.10 Named Characters Section 12.11 Properties Section 12.12 Whitespace Section 12.13 Unconstrained Repetitions Section 12.14 Capturing Parentheses Section 12.15 Captured Values Section 12.16 Capture Variables Section 12.17 Piecewise Matching Section 12.18 Tabular Regexes Section 12.19 Constructing Regexes Section 12.20 Canned Regexes Section 12.21 Alternations Section 12.22 Factoring Alternations Section 12.23 Backtracking Section 12.24 String Comparisons Chapter 13 Error Handling Section 13.1 Exceptions Section 13.2 Builtin Failures Section 13.3 Contextual Failure Section 13.4 Systemic Failure Section 13.5 Recoverable Failure Section 13.6 Reporting Failure Section 13.7 Error Messages Section 13.8 Documenting Errors Section 13.9 OO Exceptions Section 13.10 Volatile Error Messages Section 13.11 Exception Hierarchies Section 13.12 Processing Exceptions Section 13.13 Exception Classes Section 13.14 Unpacking Exceptions Chapter 14 Command-Line Processing Section 14.1 Command-Line Structure Section 14.2 Command-Line Conventions Section 14.3 Meta-options Section 14.4 In-situ Arguments Section 14.5 Command-Line Processing Section 14.6 Interface Consistency Section 14.7 Interapplication Consistency Chapter 15 Objects Section 15.1 Using OO Section 15.2 Criteria Section 15.3 Pseudohashes Section 15.4 Restricted Hashes Section 15.5 Encapsulation Section 15.6 Constructors Section 15.7 Cloning Section 15.8 Destructors Section 15.9 Methods Section 15.10 Accessors Section 15.11 Lvalue Accessors Section 15.12 Indirect Objects Section 15.13 Class Interfaces Section 15.14 Operator Overloading Section 15.15 Coercions Chapter 16 Class Hierarchies Section 16.1 Inheritance Section 16.2 Objects Section 16.3 Blessing Objects Section 16.4 Constructor Arguments Section 16.5 Base Class Initialization Section 16.6 Construction and Destruction Section 16.7 Automating Class Hierarchies Section 16.8 Attribute Demolition Section 16.9 Attribute Building Section 16.10 Coercions Section 16.11 Cumulative Methods Section 16.12 Autoloading Chapter 17 Modules Section 17.1 Interfaces Section 17.2 Refactoring Section 17.3 Version Numbers Section 17.4 Version Requirements Section 17.5 Exporting Section 17.6 Declarative Exporting Section 17.7 Interface Variables Section 17.8 Creating Modules Section 17.9 The Standard Library Section 17.10 CPAN Chapter 18 Testing and Debugging Section 18.1 Test Cases Section 18.2 Modular Testing Section 18.3 Test Suites Section 18.4 Failure Section 18.5 What to Test Section 18.6 Debugging and Testing Section 18.7 Strictures Section 18.8 Warnings Section 18.9 Correctness Section 18.10 Overriding Strictures Section 18.11 The Debugger Section 18.12 Manual Debugging Section 18.13 Semi-Automatic Debugging Chapter 19 Miscellanea Section 19.1 Revision Control Section 19.2 Other Languages Section 19.3 Configuration Files Section 19.4 Formats Section 19.5 Ties Section 19.6 Cleverness Section 19.7 Encapsulated Cleverness Section 19.8 Benchmarking Section 19.9 Memory Section 19.10 Caching Section 19.11 Memoization Section 19.12 Caching for Optimization Section 19.13 Profiling Section 19.14 Enbugging Appendix A Essential Perl Best Practices Appendix B Perl Best Practices Section B.1 Chapter 2, Code Layout Section B.2 Chapter 3, Naming Conventions Section B.3 Chapter 4, Values and Expressions Section B.4 Chapter 5, Variables Section B.5 Chapter 6, Control Structures Section B.6 Chapter 7, Documentation Section B.7 Chapter 8, Built-in Functions Section B.8 Chapter 9, Subroutines Section B.9 Chapter 10, I/O Section B.10 Chapter 11, References Section B.11 Chapter 12, Regular Expressions syntactic consistency system function 2nd 3rd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] t/ subdirectory 2nd 3rd tables array naming conventions best practice command-line processing and look-up 2nd 3rd regular expressions and slice factoring and ternary operator and 2nd vertical alignment tabs best practice code layout and 2nd empty strings and tainted( ) subroutine 2nd technical documentation 2nd 3rd Template::Toolkit module (CPAN) templates BBEdit editor and best practices 2nd creating modules for comments 2nd for documentation grammar rules and Smart::Comments module and TextWrangler editor and terminal elements (arrays) terminators, heredoc 2nd ternaries best practice 2nd code layout 2nd tabular ternary operator (?:) 2nd test cases adding for bugs best practices debugging and testing failure 2nd overview 2nd scope of test suites best practice failure and fixing overview 2nd scope of Test::Harness module 2nd 3rd Test::More module 2nd 3rd Test::Simple module 2nd 3rd Test::Tutorial module Test::Utils module testing best practice boolean names and cascaded equality eq comparisons failed boolean failure 2nd 3rd 4th flags and for interactivity interfaces and list membership 2nd missing argument and modular 2nd negative control statements and overview print statements and scope of 2nd strictures and strings and tabular ternaries and use warnings pragma 2nd warning-free compilation and text strings \t best practice boundary anchors comparisons 2nd contextual return values conversion subroutines for delimiters for empty end of string evaluating multiline reversing characters in single-character 2nd testing and 2nd unrecognized identifiers as vstrings as Text::Autoformat module (CPAN) 2nd Text::CSV module (CPAN) Text::CSV::Simple module (CPAN) 2nd Text::CSV_XS module (CPAN) 2nd TextWrangler editor theredoc thin commas 2nd 3rd throw( ) statement tied filehandles tied variables Time::HiRes module 2nd Time::HiRes::usleep function total_size( ) subroutine 2nd 3rd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] unary operators underscore (_) best practice identifiers and naming conventions readability and 2nd utility subroutines and uniq( ) subroutine 2nd UNIVERSAL class 2nd unless keyword unlock_hash( ) subroutine unlock_keys( ) subroutine unlock_value( ) subroutine unpack function 2nd unpacking best practices 2nd command lines exceptions until keyword USAGE template use base pragma use charnames pragma use constant pragma 2nd 3rd use English pragma $WARNINGS variable best practices comments and match variables punctuation variables and slurping and use Fatal pragma 2nd use IO::Handle pragma use only pragma use overload pragma use Readonly pragma 2nd use strict pragma barewords and 2nd declarative exporting and dereferencing and encapsulation and overview symbolic references and warning-free compilation and use version pragma use warnings pragma 2nd user documentation 2nd 3rd usleep( ) subroutine 2nd utilities 2nd utility subroutines best practice functionality listed naming conventions writing Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] value switches 2nd values barewords 2nd best practices 2nd 3rd captured constants and empty strings escaped characters 2nd extracting fat commas flags and here documents and heredoc indentation heredoc quoters 2nd heredoc terminators iterative list-returning subroutine leading zeros 2nd list membership 2nd lists and long numbers 2nd low-precedence operators multiline strings renaming single-character strings 2nd string delimiters tabular ternaries and testing considerations thin commas 2nd values function 2nd variable-width data 2nd variables alias array indices and best practices 2nd 3rd 4th boolean values and breaking assignments 2nd caching and capitalization of capture 2nd code layout and dollar-underscore and exporting from modules global 2nd 3rd heredocs and initialization interfaces and 2nd interpolating iterator 2nd 3rd match 2nd name templates for naming conventions 2nd package punctuation reference 2nd 3rd slice factoring slice layouts slicing tied vertical alignment and verbose option (Carp) version module (CPAN) 2nd 3rd version numbers best practice modules and 2nd requirements VERSION template 2nd vertical alignment best practice code layout and importance of leading zeros and vi editor 2nd vile editor vim editor 2nd 3rd 4th vstrings Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] wantarray function warehoused attributes warn function warn statement warnings best practices 2nd testing/debugging 2nd 3rd weaken( ) subroutine 2nd 3rd WeakRef module (CPAN) while statement checking CSV syntax for loops and implicit returns and input loops and module interfaces and postfix looping and readability redo statement and 2nd Smart::Comments module and WIFEXITED( ) subroutine Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] x command X::EOF exception handler exception classes and 2nd OO exceptions and unpacking exceptions XML 2nd XML::Parser module (CPAN) 2nd xsubpp tool Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] YAML module (CPAN) Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] zeros best practice leading 2nd module interfaces and testing considerations zip( ) subroutine 2nd ... 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 Perl Best Practices By Damian Conway Publisher: O'Reilly Pub Date: July 2005. .. 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... "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

Ngày đăng: 26/03/2019, 17:11

Mục lục

  • Perl Best Practices

  • Table of Contents

  • Copyright

  • Dedication

  • Preface

    • Contents of This Book

    • Conventions Used in This Book

    • Code Examples

    • Feedback

    • Acknowledgments

    • Chapter 1.  Best Practices

      • Section 1.1.  Three Goals

      • Section 1.2.  This Book

      • Section 1.3.  Rehabiting

      • Chapter 2.  Code Layout

        • Section 2.1.  Bracketing

        • Section 2.2.  Keywords

        • Section 2.3.  Subroutines and Variables

        • Section 2.4.  Builtins

        • Section 2.5.  Keys and Indices

        • Section 2.6.  Operators

        • Section 2.7.  Semicolons

        • Section 2.8.  Commas

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan