5 minimums for any perl script?
David Cantrell
david at cantrell.org.uk
Mon Jan 30 12:48:13 GMT 2012
On Sun, Jan 29, 2012 at 09:02:41PM +0000, Leo Lapworth wrote:
> 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+?)
>
> Mine:
>
> 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
I disagree strongly with 2 and 4. They're nice to have, but nothing
like as important as things like:
* use a version control system
* always write documentation
--
David Cantrell | http://www.cantrell.org.uk/david
Deck of Cards: $1.29.
"101 Solitaire Variations" book: $6.59.
Cheap replacement for the one thing Windows is good at: priceless
-- Shane Lazarus
More information about the london.pm
mailing list