Maintainer Efficiency
Code that you (or your friends) are going to use and work on for a long time into the future deserves more attention. Substitute some short-term gains for much better long-term benefits.
Don’t use defaults.
Use
foreachto meanforeach.Use meaningful loop labels with
nextandlast.Use meaningful variable names.
Use meaningful subroutine names.
Put the important thing first on the line using
and,or, and statement modifiers (likeexit if $done).Close your files as soon as you’re done with them.
Use packages, modules, and classes to hide your implementation details.
Make a sensible API.
Pass arguments as subroutine parameters.
Name your subroutine parameters using
my.Parenthesize for clarity.
Put in lots of (useful) comments.
Include embedded pod documentation.
use warnings.use strict.Write tests and get good test coverage (see Chapter 19).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access