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:
or via the regular
cpan install utility:
And then, you can use the provided
perltidy utility program
to reformat your code.
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.
# via cpanminus cpanm Perl-Critic # via the classic 'cpan' installation tool cpan Perl-Critic
$ perlcritic some_script.pl
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 https://github.com/exercism/perl5/issues if you have suggestions, or submit a patch with improvements to the https://github.com/exercism/perl5/blob/master/docs/RESOURCES.md file.