Ten Essential Coding Practices
- Always use strict and use warnings.[Chapter 18: Strictures , Warnings ]
- Use grammatical templates when forming identifiers.[Chapter 3: Identifiers, Booleans, Reference Variables, Arrays and Hashes ]
- Use lexical variables, not package variables.[Chapter 5: Lexical Variables ]
- Label every loop that is exited explicitly, and every next, last, or redo.[Chapter 6: Loop Labels ]
- Don't use bareword filehandles; use indirect filehandles.[Chapter 10: Filehandles, Indirect Filehandles ]
- In a subroutine, always unpack @_ first, using a hash of named arguments if there are more than three parameters.[Chapter 9: Argument Lists, Named Arguments ]
- Always return via an explicit return.[Chapter 9: Implicit Returns ]
- Always use the /x, /m, and /s flags, and the \A and \z anchors.[Chapter 12: Extended Formatting, Line Boundaries, Matching Anything, String Boundaries ]
- Use capturing parentheses in regexes only when deliberately capturing, then give the captured substrings proper names.[Chapter 12: Capturing Parentheses, Capture Variables ]
- Never make variables part of a module's interface.[Chapter 17: Interface Variables ]
|