Archive for the ‘Perl Best Practices’ Category

PBP: 007 Semicolons

Thursday, May 22nd, 2014

The suggestion here is to place a semicolon after every statement.  I agree with this, even if it isn’t technically needed.  The only place I’ll skip it is if it is a function returning a constant value, and that’s all that is in the function, like this: (more…)

PBP: 006 Operators

Monday, May 19th, 2014

PBP says to put whitespace around binary operators.  This, I entirely agree with.  It also notes to keep unary operators together with their operand.  This, too, I think is a good idea. (more…)

PBP: 005 Keys and Indices

Thursday, May 15th, 2014

The PBP suggests putting whitespace between keys or indices and their brackets.
I find this a good suggestion, although I forget to do it sometimes.  I do it for all complex statements, but forget for simple cases.
This is a place perltidy is a big help.

PBP: 004 Builtins

Monday, May 12th, 2014

The suggestion in this section is not to use parenthesis for builtins and builtin-like functions.
I’m not sure why differentiating between builtins and functions is particularly useful, but I don’t object to the idea and found it easy to get used to.

PBP: 003 Subroutines and Variables

Sunday, May 11th, 2014

The item in this category is not to separate the parenthesis from a function call by a space.  This is sort of the converse of the last practice, and needed to help show a function call from a control structure.

I find this good advice, too, for the reasons given.

PBP: 002 Keywords

Saturday, May 10th, 2014

The PBP suggests putting a space between a keyword and the opening parenthesis, to help differentiate it from a subroutine call.
This is a good idea, for good reasons.

PBP: 001 Bracketing

Thursday, May 8th, 2014

The PBP suggests the venerable K&R bracer style.  I don’t have a strong feeling on this.
I have used several styles over the years, and mildly prefer the Allman style, which the book calls BSD.  I find the GNU style of half-indents bizarre.

(more…)

Examining the book “Perl Best Practices”

Thursday, May 8th, 2014

Perl Best PracticesMost people who use Perl seriously have seen Damian Conway‘s book Perl Best Practices.  It was, and is, an important book and has a lot of interesting discussions in it.

I don’t find all the suggestions in PBP to be useful, though.  Since I’ve just been thinking about them, I thought I’d write them up.  Why not go through them all?
(more…)