Skip to content
Ulrich Habel edited this page Nov 27, 2010 · 4 revisions

Perl::Tidy to the rescue

Keeping code well formatted is not vital, however, it reduces the cost of maintainance and it raises acceptance among co-workers. Whenever someone looks into code snippets which vary all over the place the results are unpredicatable. There are reasonable tools on the market which tests your code and formats it.

A common one is the Perl module Perl::Tidy. Perl::Tidy let's you specify the way your code is being formatted by using a configuration file named ~/.perltidyrc. The Mojolicious github repository has a nice perltidyrc included. Why not using the way the Mojolicious project format the code?

  • Install Perl::Tidy (easiest way: cpan Perl::Tidy)

  • Download the perltidyrc file from the Mojolicious repo and install it inside your home directory.

    perl -Mojo -e 'print g("http://github.com/kraih/mojo/raw/master/.perltidyrc")->body' \
    > ~/.perltidyrc
  • perltidy will use the default configuration file named ~/.perltidyrc if no further options are give. You can use a different perltidyrc file using the command option -pro=<perltidyrc>.

  • Format your sources (perltidy <sourcefile>)

Clone this wiki locally