Perl ベストプラクティス 気になったもの

3.1. Identifiers
Use grammatical templates when forming identifiers.



4.5. Constants
Use named constants, but don't use constant.


4.10. Heredoc Indentation
Use a "theredoc" when a heredoc would compromise your indentation.



4.18. List Membership
Use table-lookup to test for membership in lists of strings; use any( ) for membership of lists of anything else.



5.2. Package Variables
Don't use package variables in your own development.


5.4. Initialization
Initialize any variable you localize.


5.11. Slice Layout
Use a tabular layout for slices.



6.10. List Generation
Use map instead of for when generating new lists from old.


7.11. Defensive Documentation
Comment anything that has puzzled or tricked you.


7.12. Indicative Documentation
Consider whether it's better to rewrite than to comment.


7.13. Discursive Documentation
Use "invisible" POD sections for longer technical discussions


8.1. Sorting
Don't recompute sort keys inside a sort.


8.4. Fixed-Width Data
Use unpack to extract fixed-width fields.


8.5. Separated Data
Use split to extract simple variable-width fields.


8.6. Variable-Width Data
Use Text::CSV_XS to extract complex variable-width fields.


8.14. Utilities
Use the "non-builtin builtins".


9.1. Call Syntax
Call subroutines with parentheses but without a leading &.


9.3. Argument Lists
Always unpack @_first.


10.7. Input Loops
Use while (<>), not for (<>).


10.9. Simple Slurping
Slurp a filehandle with a do block for purity.


10.10. Power Slurping
Slurp a stream with Perl6::Slurp for power and simplicity.


10.17. Automatic Progress Indicators
Consider using the Smart::Comments module to automate your progress indicators.


12.20. Canned Regexes
Consider using Regexp::Common instead of writing your own regexes.


18.13. Semi-Automatic Debugging
Consider using "smart comments" when debugging, rather than warn statements.