2 Dec 2010

Perl Best practices - Coding

Ten Essential Coding Practices by Damien conway in PBP book

1. Always use strict and use warnings.

2. Use grammatical templates when forming identifiers.

3. Use lexical variables, not package variables.

4. Label every loop that is exited explicitly, and every next, last, or redo.

5. Don’t use bareword filehandles; use indirect filehandles.

6. In a subroutine, always unpack @_ first, using a hash of named arguments if
there are more than three parameters.

7. Always return via an explicit return.

8. Always use the /x ,/m , and /s flags, and the \A and \z anchors.

9. Use capturing parentheses in regexes only when deliberately capturing, then give
the captured substrings proper names.

10. Never make variables part of a module’s interface.

No comments:

Post a Comment