Code Style and Linting

If you are looking for good general advices regarding Perl coding, Damian Conway's Perl Best Practices is a good reference.

To prettify your code, you can use the module Perl-Tidy.

To install with cpanminus:

cpanm Perl-Tidy

or via the regular cpan install utility:

cpan Perl-Tidy

And then, you can use the provided perltidy utility program to reformat your code.

# modify file in-place and save old version as
$ perltidy -b

perltidy has a lot of configuration options to cater to every taste. They are documented here.

There is also tidyview, a visual interface that allows you to tweak the different options and immediately see the result.

If you want to enforce coding practices, there is also Perl::Critic. It comes with the rules described in the book Perl Best Practices mentioned previously, but plenty of plugins exist, and it can be customized to fit any in-house coding rules.

To install:

# via cpanminus
cpanm Perl-Critic

# via the classic 'cpan' installation tool
cpan Perl-Critic

To use:

$ perlcritic

The tool has many, many configuration tweaks, see its documentation for the full scoop on them.

Help us explain this better! File a GitHub issue at if you have suggestions, or submit a patch with improvements to the file.