5 minimums for any perl script?

Leo Lapworth leo at cuckoo.org
Sun Jan 29 21:02:41 GMT 2012


I've been asked what would be a good minimum to have as a coding police
for a company that isn't focused on Perl, but uses it occasionally. So if
Perl Best Practices is too much, and you could only have 5 rules for any
perl script, what would they be?

(let's assume recent 5.10+?)


1) use strict; use warnings;
- obvious why

2) all files to be perl tidied (ideally automatically)
- it makes reading code easier, as long as there is a standard

3) All variable names to be clear about what they contain, no short
variable names unless in a small loop (e.g. $i)
- "But I know $e means...." doesn't help me in reading code

4) use Path::Class and always keep files/dirs as Path::Class objects
as long as possible
- this is a strange one, but it's more about being consistent and having
  $file->slurp; $file->openw() $dir->mkpath(). It seems to make code
cleaner, others have
  suggested IO::Any, but that still has missing / odd behaviour for my
liking at the moment

5) Always ask one other person to review your code

What would yours be?


More information about the london.pm mailing list