Perl最佳实践(影印版)
Perl最佳实践(影印版)
Damian Conway
出版时间:2006年04月
页数:517
许多程序员凭直觉来编程,这些直觉来自于他们早期养成的习惯和风格。这样写出的程序似乎自然、直观,而且看起来也很不错。但是,如果你想严肃地对待程序员这份职业,那么直觉就远远不够了。《Perl最佳实践》讲述了许多关于Perl语言的编程规则、使用惯例、开发标准和最佳实践,这些内容不仅有助于程序员之间的交流和协同工作,同时也提供了一套思考问题的可靠框架和一种表述解决方案的通用语言。
通过生动幽默的表达,作者Damian Conway为Perl编程人员提供了关于编程艺术的256条规则,这些规则能帮助你编写出更好的Perl代码。这些规则涵盖了代码布局和命名规则,数据和控制结构的选择,程序解构和模块化,接口的设计和实现,面向对象设计,错误处理、程序测试和调试。
本书中所有的规则都是为了写出清晰、健壮、高效、可维护和简洁的程序而设计。Conway博士并不自诩这些规则是最广泛和最清晰的实践集,但实际上,本书确实提供了在实践中被广泛认可和应用的建议,而不是象牙塔似的编程理论。
最特别地是,《Perl最佳实践》提供的规则是实在有效的,世界各地的开发人员已经普遍使用。像Perl语言的初衷一样,这些规则将使你的开发更加出色。
“作为一个大型Perl项目的开发经理,我确信我的开发团队的每个成员都会把《Perl最佳实践》放在手边,并将它作为开发准测。”
—— Randal Schwartz
“这本书的出现使开发人员不再有任何借口写出糟糕的Perl程序。读过这本书后,所有的Perl开发人员的工作都会更加高效。”
—— Peter Scott, Perl trainer and author
“《Perl最佳实践》已经帮我节省了大量的时间,同时,‘部门编码规范’的编写不再是难事。”
—— Andy Lester, Web Applications Manager, Follett Library Resources
“Damian完成的工作是难以置信的,不仅展现了如何构建大型的、可维护的Perl应用,同时,将Perl语言的强大表达力展现在我们面前。”
—— Bill Odom, Perl Foundation Steering Committee Chairman
  1. Preface
  2. 1. Best Practices
  3. Three Goals
  4. This Book
  5. Rehabiting
  6. 2. Code Layout
  7. Bracketing
  8. Keywords
  9. Subroutines and Variables
  10. Builtins
  11. Keys and Indices
  12. Operators
  13. Semicolons
  14. Commas
  15. Line Lengths
  16. Indentation
  17. Tabs
  18. Blocks
  19. Chunking
  20. Elses
  21. Vertical Alignment
  22. Breaking Long Lines
  23. Non-Terminal Expressions
  24. Breaking by Precedence
  25. Assignments
  26. Ternaries
  27. Lists
  28. Automated Layout
  29. 3. Naming Conventions
  30. Identifiers
  31. Booleans
  32. Reference Variables
  33. Arrays and Hashes
  34. Underscores
  35. Capitalization
  36. Abbreviations
  37. Ambiguous Abbreviations
  38. Ambiguous Names
  39. Utility Subroutines
  40. 4. Values and Expressions
  41. String Delimiters
  42. Empty Strings
  43. Single-Character Strings
  44. Escaped Characters
  45. Constants
  46. Leading Zeros
  47. Long Numbers
  48. Multiline Strings
  49. Here Documents
  50. Heredoc Indentation
  51. Heredoc Terminators
  52. Heredoc Quoters
  53. Barewords
  54. Fat Commas
  55. Thin Commas
  56. Low-Precedence Operators
  57. Lists
  58. List Membership
  59. 5. Variables
  60. Lexical Variables
  61. Package Variables
  62. Localization
  63. Initialization
  64. Punctuation Variables
  65. Localizing Punctuation Variables
  66. Match Variables
  67. Dollar-Underscore
  68. Array Indices
  69. Slicing
  70. Slice Layout
  71. Slice Factoring
  72. 6. Control Structures
  73. If Blocks
  74. Postfix Selectors
  75. Other Postfix Modifiers
  76. Negative Control Statements
  77. C-Style Loops
  78. Unnecessary Subscripting
  79. Necessary Subscripting
  80. Iterator Variables
  81. Non-Lexical Loop Iterators
  82. List Generation
  83. List Selections
  84. List Transformation
  85. Complex Mappings
  86. List Processing Side Effects
  87. Multipart Selections
  88. Value Switches
  89. Tabular Ternaries
  90. do-while Loops
  91. Linear Coding
  92. Distributed Control
  93. Redoing
  94. Loop Labels
  95. 7. Documentation
  96. Types of Documentation
  97. Boilerplates
  98. Extended Boilerplates
  99. Location
  100. Contiguity
  101. Position
  102. Technical Documentation
  103. Comments
  104. Algorithmic Documentation
  105. Elucidating Documentation
  106. Defensive Documentation
  107. Indicative Documentation
  108. Discursive Documentation
  109. Proofreading
  110. 8. Built-in Functions
  111. Sorting
  112. Reversing Lists
  113. Reversing Scalars
  114. Fixed-Width Data
  115. Separated Data
  116. Variable-Width Data
  117. String Evaluations
  118. Automating Sorts
  119. Substrings
  120. Hash Values
  121. Globbing
  122. Sleeping
  123. Mapping and Grepping
  124. Utilities
  125. 9. Subroutines
  126. Call Syntax
  127. Homonyms
  128. Argument Lists
  129. Named Arguments
  130. Missing Arguments
  131. Default Argument Values
  132. Scalar Return Values
  133. Contextual Return Values
  134. Multi-Contextual Return Values
  135. Prototypes
  136. Implicit Returns
  137. Returning Failure
  138. 10. I/O
  139. Filehandles
  140. Indirect Filehandles
  141. Localizing Filehandles
  142. Opening Cleanly
  143. Error Checking
  144. Cleanup
  145. Input Loops
  146. Line-Based Input
  147. Simple Slurping
  148. Power Slurping
  149. Standard Input
  150. Printing to Filehandles
  151. Simple Prompting
  152. Interactivity
  153. Power Prompting
  154. Progress Indicators
  155. Automatic Progress Indicators
  156. Autoflushing
  157. 11. References
  158. Dereferencing
  159. Braced References
  160. Symbolic References
  161. Cyclic References
  162. 12. Regular Expressions
  163. Extended Formatting
  164. Line Boundaries
  165. String Boundaries
  166. End of String
  167. Matching Anything
  168. Lazy Flags
  169. Brace Delimiters
  170. Other Delimiters
  171. Metacharacters
  172. Named Characters
  173. Properties
  174. Whitespace
  175. Unconstrained Repetitions
  176. Capturing Parentheses
  177. Captured Values
  178. Capture Variables
  179. Piecewise Matching
  180. Tabular Regexes
  181. Constructing Regexes
  182. Canned Regexes
  183. Alternations
  184. Factoring Alternations
  185. Backtracking
  186. String Comparisons
  187. 13. Error Handling
  188. Exceptions
  189. Builtin Failures
  190. Contextual Failure
  191. Systemic Failure
  192. Recoverable Failure
  193. Reporting Failure
  194. Error Messages
  195. Documenting Errors
  196. OO Exceptions
  197. Volatile Error Messages
  198. Exception Hierarchies
  199. Processing Exceptions
  200. Exception Classes
  201. Unpacking Exceptions
  202. 14. Command-Line Processing
  203. Command-Line Structure
  204. Command-Line Conventions
  205. Meta-options
  206. In-situ Arguments
  207. Command-Line Processing
  208. Interface Consistency
  209. Interapplication Consistency
  210. 15. Objects
  211. Using OO
  212. Criteria
  213. Pseudohashes
  214. Restricted Hashes
  215. Encapsulation
  216. Constructors
  217. Cloning
  218. Destructors
  219. Methods
  220. Accessors
  221. Lvalue Accessors
  222. Indirect Objects
  223. Class Interfaces
  224. Operator Overloading
  225. Coercions
  226. 16. Class Hierarchies
  227. Inheritance
  228. Objects
  229. Blessing Objects
  230. Constructor Arguments
  231. Base Class Initialization
  232. Construction and Destruction
  233. Automating Class Hierarchies
  234. Attribute Demolition
  235. Attribute Building
  236. Coercions
  237. Cumulative Methods
  238. Autoloading
  239. 17. Modules
  240. Interfaces
  241. Refactoring
  242. Version Numbers
  243. Version Requirements
  244. Exporting
  245. Declarative Exporting
  246. Interface Variables
  247. Creating Modules
  248. The Standard Library
  249. CPAN
  250. 18. Testing and Debugging
  251. Test Cases
  252. Modular Testing
  253. Test Suites
  254. Failure
  255. What to Test
  256. Debugging and Testing
  257. Strictures
  258. Warnings
  259. Correctness
  260. Overriding Strictures
  261. The Debugger
  262. Manual Debugging
  263. Semi-Automatic Debugging
  264. 19. Miscellanea
  265. Revision Control
  266. Other Languages
  267. Configuration Files
  268. Formats
  269. Ties
  270. Cleverness
  271. Encapsulated Cleverness
  272. Benchmarking
  273. Memory
  274. Caching
  275. Memoization
  276. Caching for Optimization
  277. Profiling
  278. Enbugging
  279. A. Essential Perl Best Practices
  280. B. Perl Best Practices
  281. C. Editor Configurations
  282. D. Recommended Modules and Utilities
  283. E. Bibliography
  284. Index
书名:Perl最佳实践(影印版)
作者:Damian Conway
国内出版社:东南大学出版社
出版时间:2006年04月
页数:517
书号:7-5641-0163-6
原版书出版商:O'Reilly Media
Damian Conway
 
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 has been a member of the technical committee for The Perl
Conference, a keynote speaker at many Open Source conferences, is a former columnist
for The Perl Journal, and is 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 Damian’s time is now spent working with Larry Wall on the design of the
new Perl 6 programming language.
 
 
The animal on the cover of Perl Best Practices is an American staghound,a hybrid of the greyhound and the Scottish deerhound that is bred specifically for coursing,or hunting by sight.Coursing is one of the world's oldest field sports, and “gazehounds,”or “sighthounds,” have been tested in competition since as early as AD 116.
The staghound is not recognized as a breed, but is considered a type of sighthound.
Although some lines of staghounds have been bred together since the 1700s—longer than some modern breeds—most huntsmen don't push for breed recognition.They believe the staghound should be left unrecognized in order to preserve it as a coursing animal bred for function and not form.As a result, there are no breed standards.
Staghounds come in any color or pattern found in either the greyhound or
Scottish deerhound and have three coat types: “shag,” “slick,” and “broken” (which is between shag and slick).
The staghound exhibits many of the same physical characteristics as the greyhound,with long legs, strong muscles, a deep chest, and keen eyesight, and has the enduranceand scenting ability of the Scottish deerhound.The staghound's coursing instinct is so strong that anything that runs—rabbits,deer,coyotes,etc.—may be
considered quarry.Because these dogs are fast and alert but not hyper or aggressive,they are also said to make excellent pets if exercised regularly.
购买选项
定价:74.00元
书号:7-5641-0163-6
出版社:东南大学出版社