PerlTidy Perltidy is a Perl script which indents and reformats Perl scripts to make them easier to read. If you write Perl scripts, or spend much time reading them, you will probably find it useful.

The simplest usage is perltidy -b which will tidy the module inplace, using the default settings.

Be careful not to mix up functional changes you make to code with formatting changes. It's a good idea to reformat any code you are going to change before you start, and then check in just the formatting changes first, if there are any.

IDEA! Foswiki's subversion server checks commits of .pm and .pl files for the core and some extensions (such as Foswiki's core/default extensions). It uses the Perl::Tidy module included in the BuildContrib to do this. If you have BuildContrib locally (recommended) then you can easily configure perltidy to use it. Simply export PERL5LIB=/the/path/to/BuildContrib/lib and run perltidy as usual (Linux bash, other OS's/shells will have a similar feature). See CodingStandards#Formatting_Code

Versions runs perltidy v20120714 (or later) which produces differently formatted files to the older v2010.... versions that are still found in many Linux distributions. If you're trying to commit changes to perl files on a TIDY controlled extension, your commits may be rejected unless you're tidying with the newer version of perltidy.

BuildContrib ships with the correct version of Perl::Tidy built into it. Using the perl tidy target will format your code using that version, thus avoiding any checkin problems.
Topic revision: r8 - 04 Feb 2014, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy