A Perl script beautifier
Version: 20090616Perltidy 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.
License: GPL
Operating System: Linux
Homepage: perltidy.sourceforge.net
Developed by:
Configuration Files
While style preferences vary, most people would agree that it is important to maintain a uniform style within a script, and this is a major benefit provided by perltidy. Once you have decided on which, if any, special options you prefer, you may want to avoid having to enter them each time you run it. You can do this by creating a special file named .perltidyrc in either your home directory, your current directory, or certain system-dependent locations. (Note the leading ``.'' in the file name).
A handy command to know when you start using a configuration file is
perltidy -dpro
which will dump to standard output the search that perltidy makes when looking for a configuration file, and the contents of the one that it selects, if any. This is one of a number of useful ``dump and die'' commands, in which perltidy will dump some information to standard output and then immediately exit. Others include -h, which dumps help information, and -v, which dumps the version number.
Another useful command when working with configuration files is
perltidy -pro=file
which causes the contents of file to be used as the configuration file instead of a .perltidyrc file. With this command, you can easily switch among several different candidate configuration files during testing.
This .perltidyrc file is free format. It is simply a list of parameters, just as they would be entered on a command line. Any number of lines may be used, with any number of parameters per line, although it may be easiest to read with one parameter per line. Blank lines are ignored, and text after a '#' is ignored to the end of a line.
Here is an example of a .perltidyrc file:
This is a simple of a .perltidyrc configuration file
This implements a highly spaced style
- bl # braces on new lines
- pt=0 # parens not tight at all
- bt=0 # braces not tight
- sbt=0 # square brackets not tight
If you experiment with this file, remember that it is in your directory, since if you are running on a Unix system, files beginning with a ``.'' are normally hidden.
If you have a .perltidyrc file, and want perltidy to ignore it, use the -npro flag on the command line.
Installation
For most standard installations, the standard Makefile.PL method should work:
perl Makefile.PL
make
make test
make install
The INSTALL file has additional installation notes.