Archive for the ‘Perl Best Practices’ Category

PBP: 106 Automating Sorts

Thursday, July 2nd, 2015

The PBP suggests using a module called Sort::Maker to build powerful sort functions without getting hung up in the details and possibly messing up the implementation. (more…)

PBP: 105 Avoid string eval

Monday, June 29th, 2015

The Best Practices suggest avoiding string eval. (more…)

PBP: 104 Variable-Width Data

Thursday, June 25th, 2015

The Best Practices suggest using CPAN modules for more complex data parsing, instead of trying to roll your own. (more…)

PBP: 103 Separated Data

Monday, June 22nd, 2015

The Book suggests using split to take apart separated data with simple separators. (more…)

PBP 102: Fixed-width Data

Thursday, June 18th, 2015

The PBP suggests we use unpack to take apart fixed-width data. (more…)

PBP: 101 Reversing Scalars

Monday, June 15th, 2015

The PBP suggests that when you want to reverse a scalar, you explicitly state this with ‘scalar reverse $variable’ instead of just using reverse on it.  It suggests this both makes explicit, and regularizes the use, regardless of the context it is called in.

I don’t like this suggestion and don’t feel it is needed, but I won’t object to it because of the clear example in the book that makes it clear how it helps.  I find the demand you add a ‘scalar’ all the time because sometimes it’s unclear to be a problem.  I’ll probably turn off the critic warning for this, but I won’t say it’s too horrible.

PBP: 100 Reversing Lists

Thursday, June 11th, 2015

Mr. Conway suggets using the reverse builtin when appropriate.  This includes with sort, and for counting backwards. (more…)

PBP: 099 Sorting

Monday, June 8th, 2015

The Best Practices have things to say about many of Perl’s built-in functions.  Besides the general advice “use them” – which I agree with – it has some specific suggestions.  First up: Sorting (more…)

PBP: 098 Proofreading

Monday, June 1st, 2015

It is a Best Practice to check the spelling, syntax, and sanity of your documentation.  I agree with this, strongly. (more…)

PBP: 097 Discursive Documentation

Thursday, May 7th, 2015

The PBP suggests a way to put longer blocks of documentation in code, by using the =for or =begin/=end notation in POD.  By labeling these with a “formatter” that does not exist, they’ll never be output and are merely ignored by the compiler and for the author’s use. (more…)