Perl Best Practices - Perl::Critic

The book Perl Best Practices of Damian Conway provides a reasonable set of guidelines on how to write a Perl program. While you might not want to follow each guideline as it is written in the book it can be a very good starting point. It is certainly much better than the current practice of letting everyone write whatever she wants. This is good in the general terms and when we are talking about individual projects. Within a project (or within a company) it makes a lot of sense to stick to some guidelines.

So reading the book is good. In addition there is a module called Perl::Critic by Jeffrey Ryan Thalhammer and currently maintained by Elliot Shank that can check each one of the practices Damian suggest. Not only that.

There is also a module called Test::Perl::Critic that takes the functions of Perl::Critic and turns them into Test::Builder based functions. So you can get ok/not ok output from them.

Using them in Perl projects can help improving the code base very quickly.

You can also configure the module to check each one of the "practices" according to the style accepted in your company.

use strict;
use warnings;

use Test::More;
eval {
   require Test::Perl::Critic;
   import  Test::Perl::Critic;
plan skip_all => 'Test::Perl::Critic required to criticise code' if $@;
#all_critic_ok('blib', 't');