perltidy - a perl script indenter and reformatter
perltidy [ options ] file1 file2 file3 ... (output goes to file1.tdy, file2.tdy, file3.tdy, ...) perltidy [ options ] file1 -o outfile perltidy [ options ] file1 -st >outfile perltidy [ options ] <infile >outfile
Perltidy reads a perl script and writes an indented, reformatted script. The default formatting tries to follow the recommendations in perlstyle(1).
Many users will find enough information in EXAMPLES to get started. New users may benefit from the short tutorial which comes with the distribution.
The formatting can be controlled in detail with numerous input parameters, which are described in OPTIONS.
perltidy somefile.pl
This will produce a file somefile.pl.tdy containing the script reformatted using the default options, which approximate the style suggested in perlstyle(1). Perltidy never changes the input file.
perltidy *.pl
Execute perltidy on all .pl files in the current directory with the default options. The output will be in files with an appended .tdy extension. For any file with an error, there will be a file with extension .ERR.
perltidy -gnu somefile.pl
Execute perltidy on file somefile.pl with a style which approximates the GNU Coding Standards for C programs. The output will be somefile.pl.tdy.
perltidy -i=3 somefile.pl
Execute perltidy on file somefile.pl, with 3 columns for each level of indentation (-i=3) instead of the default 4 columns. There will not be any tabs in the reformatted script, except for any which already exist in comments, pod documents, quotes, and here documents. Output will be somefile.pl.tdy.
perltidy -i=3 -t somefile.pl
Same as the previous example, except that each set of 3 columns of indentation (-i=3) will be represented by one leading tab character (-t).
perltidy -ce -l=72 somefile.pl
Execute perltidy on file somefile.pl with all defaults except use ``cuddled elses'' (-ce) and a maximum line length of 72 columns (-l=72) instead of the default 80 columns.
perltidy -g somefile.pl
Execute perltidy on file somefile.pl and save a log file somefile.pl.LOG which shows the nesting of braces, parentheses, and square brackets at the start of every line.
The entire command line is scanned for options, and they are processed before any files are processed. As a result, it does not matter whether flags are before or after any filenames. However, the relative order of parameters is important, with later parameters overriding the values of earlier parameters.
For each parameter, there is a long name and a short name. The short names are convenient for keyboard input, while the long names are self-documenting and therefore useful in scripts. It is customary to use two leading dashes for long names, but one may be used.
Most parameters which serve as on/off flags can be negated with a leading ``n'' (for the short name) or a leading ``no'' (for the long name). For example, the flag to use tabs is -t or --tabs. The flag to use no tabs (the default) is -nt or --notabs.
Options may not be bundled together. In other words, options -q and -g may NOT be entered as -qg.
Option names may be terminated early as long as they are uniquely identified. For example, instead of -dump-token-types, it would be sufficient to enter -dump-tok, or even -dump-t, to uniquely identify this command.
The following parameters concern the files which are read and written.
perltidy somefile.pl -st >somefile.new.pl
This option may only be used if there is just a single input file. When this option is used, perltidy will have to create a temporary copy of the output file, perltidy.TMPO, to feed to perl for syntax checking, unless allow syntax checking is disabled. This file will be deleted when the job finishes. The default is -nst or -nostandard-output.
For example, if you use a vi-style editor, such as vim, you may execute perltidy as a filter from within the editor using something like
:n1,n2!perltidy -q
where n1,n2
represents the selected text. Without the -q flag,
any error messages will mess up your screen. Besides, it is common to
run perltidy on incomplete blocks from an editor, and you don't want to
see any complaints about that. (Or maybe you do; in that case, be
prepared to use your ``undo'' key).
perl -T -c
to check syntax of input and output.
The results are written to the .LOG file, which will be saved if an error
is detected in the output script. The output script is not checked if the
input script has a syntax error. To skip syntax checking, use -nsyn or
--nocheck-syntax. Syntax checking is also deactivated by the --quiet
flag, discussed above.
The default is to do a syntax check.
n
is
optional. If you set the flag -g without the value of n
, it will be
taken to be 1, meaning that every line will be written to the log file. This
can be helpful if you are looking for a brace, paren, or bracket nesting error.
Setting -g also causes the logfile to be saved, so it is not necessary to also include -log.
If no -g flag is given, a value of 50 will be used, meaning that at least every 50th line will be recorded in the logfile. This helps prevent excessively long log files.
Setting a negative value of n
is the same as not setting -g at all.
If you set the -npro flag, perltidy will not look for this file.
perltidy -pro=testcfg
would cause file testcfg to be used instead of the default .perltidyrc.
See also --tabs.
If you choose tabs, you will want to give the appropriate setting to your editor to display tabs as 4 blanks (or whatever value has been set with the -i command).
Except for these possible tab indentation characters, Perltidy does not introduce any tab characters into your file, and it removes any tabs from the code (unless requested not to do so with -fws). If you have any tabs in your comments, quotes, or here-documents, they will remain.
Certain commands are incompatible with tabs, and if these are given, then a warning message will be given and tabs will be deactivated. An example is the -lp option.
The default and recommendation is -nt (or --notabs).
Setting this flag is equivalent to setting --freeze-newlines and --freeze-whitespace.
my $level = # -ci=2 ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
The same example, with n=0, is a little harder to read:
my $level = # -ci=0 ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
The value given to -ci is also used by some commands when a small space is required. Examples are commands for outdenting labels, -ola, and control keywords, -ock.
When default values are not used, it is suggested that the value n given with -ci=n be no more than about one-half of the number of spaces assigned to a full indentation level on the -i=n command.
@month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
Use the -lp flag to add extra indentation to cause the data to begin past the opening parentheses of a sub call or list, or opening square bracket of an anonymous array, or opening curly brace of an anonymous hash. With this option set, the above list would become:
@month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
If the available line length (see -l=n ) does not permit this much space, perltidy will use less.
This option has no effect on code BLOCKS, such as if/then/else blocks, which always use whatever is specified with -i=n. Also, the existence of line breaks and/or block comments between the opening and closing parens may cause perltidy to temporarily revert to its default method.
Note: The -lp option may not be used together with the -t tabs option. If -t is specified, it will be ignored.
In addition, any parameter which restricts the ability of perltidy to choose newlines will all conflict with -lp and will cause -lp to be deactivated. These include -io, -fnl, -nanl, and -ndnl.
);
, };
,
or ];
indented with the same indentation as the previous line. The
previous example with -icp would give,
# perltidy -icp: @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
if ($task) { yyy(); } # -icb else { zzz(); }
The default is not to do this, indicated by -nicb.
my $i; LOOP: while ( $i = <FOTOS> ) { chomp($i); next unless $i; fixit($i); }
Labels which are already at the leftmost column will not be affected by this command. Use -nola to not outdent labels. The current default is not to outdent labels.
redo
, next
, last
,
goto
, and return
. The intention is to make these control keywords
easier to see. To change this list of keywords being outdented, see
the next section.
For example, using perltidy -ock
on the previous example gives:
my $i; LOOP: while ( $i = <FOTOS> ) { chomp($i); next unless $i; fixit($i); }
The default is not to do this.
For example, the commands -okwl="next last redo goto" -okw
will cause
those four keywords to be outdented. It is probably simplest to place
any -okwl command in a .perltidyrc file.
Whitespace refers to the blank space between variables, operators, and other code tokens.
(
then there
will be a space before the corresponding )
.
The -pt=n or --paren-tightness parameter controls the space within parens. The example below shows the effect of the three possible values, 0, 1, and 2:
if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0 if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default) if ((my $len_tab = length($tabstr)) > 0) { # -pt=2
When n is 0, there is always a space to the right of a '(' and to the left of a ')'. For n=2 there is never a space. For n=1, the default, there is a space unless the quantity within the parens is a single token, such as an identifier or quoted string.
Likewise, the parameter -sbt=n or --square-bracket-tightness controls the space within square brackets, as illustrated below.
$width = $col[ $j + $k ] - $col[ $j ]; # -sbt=0 $width = $col[ $j + $k ] - $col[$j]; # -sbt=1 (default) $width = $col[$j + $k] - $col[$j]; # -sbt=2
Curly braces which do not contain code blocks are controlled by the parameter -bt=n or --brace-tightness=n.
$obj->{ $parsed_sql->{ 'table' }[0] }; # -bt=0 $obj->{ $parsed_sql->{'table'}[0] }; # -bt=1 (default) $obj->{$parsed_sql->{'table'}[0]}; # -bt=2
And finally, curly braces which contain blocks of code are controlled by the parameter -bbt=n or --block-brace-tightness=n as illustrated in the example below.
%bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.'; # -bbt=0 (default) %bf = map { $_ => -M $_ } grep {/\.deb$/} dirents '.'; # -bbt=1 %bf = map {$_ => -M $_} grep {/\.deb$/} dirents '.'; # -bbt=2
$i = 1 ; # -sts $i = 1; # -nsts (default)
for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) { # -sfs (default) for ( @a = @$ap, $u = shift @a; @a; $u = $v ) { # -nsfs
-wls=s or --want-left-space=s,
-nwls=s or --nowant-left-space=s,
-wrs=s or --want-right-space=s,
-nwrs=s or --nowant-right-space=s.
These parameters are each followed by a quoted string, s, containing a list of token types. No more than one of each of these parameters should be specified, because repeating a command-line parameter always overwrites the previous one before perltidy ever sees it.
To illustrate how these are used, suppose it is desired that there be no space on either side of the token types = + - / *. The following two parameters would specify this desire:
-nwls="= + - / *" -nwrs="= + - / *"
(Note that the token types are in quotes, and that they are separated by spaces). With these modified whitespace rules, the following line of math:
$root = -$b + sqrt( $b * $b - 4. * $a * $c ) / ( 2. * $a );
becomes this:
$root=-$b+sqrt( $b*$b-4.*$a*$c )/( 2.*$a );
These parameters should be considered to be hints to perltidy rather than fixed rules, because perltidy must try to resolve conflicts that arise between them and all of the other rules that it uses. One conflict that can arise is if, between two tokens, the left token wants a space and the right one doesn't. In this case, the token not wanting a space takes priority.
It is necessary to have a list of all token types in order to create this type of input. Such a list can be obtained by the command -dump-token-types.
qw
quotesqw
quotes and indenting them appropriately.
-ntqw or --notrim-qw cause leading and trailing whitespace around
multi-line qw
quotes to be left unchanged. This option will not
normally be necessary, but was added for testing purposes, because in
some versions of perl, trimming qw
quotes changes the syntax tree.
Perltidy has a number of ways to control the appearance of both block comments and side comments. The term block comment here refers to a full-line comment, whereas side comment will refer to a comment which appears on a line to the right of some code.
# this comment is indented (-ibc, default) if ($task) { yyy(); }
The alternative is -nibc:
# this comment is not indented (-nibc) if ($task) { yyy(); }
See also -sbc for a way to have some indented and some outdented block comments.
my $IGNORE = 0; # This is a side comment # This is a hanging side comment # And so is this
A comment is considered to be a hanging side comment if (1) it immediately follows a line with a side comment, or another hanging side comment, and (2) there is some leading whitespace on the line. To deactivate this feature, use -nhsc or --nohanging-side-comments. If block comments are preceded by a blank line, or have no leading whitespace, they will not be mistaken as hanging side comments.
sub foo { if ( !defined( $_[0] ) ) { print("Hello, World\n"); } else { print( $_[0], "\n" ); } }
And here is the result of processing with perltidy -csc
:
sub foo { if ( !defined( $_[0] ) ) { print("Hello, World\n"); } else { print( $_[0], "\n" ); } } ## end sub foo
A closing side comment was added for sub foo
in this case, but not
for the if
and else
blocks, because they were below the 6 line
cutoff limit for adding closing side comments. This limit may be
changed with the -csci command, described below.
The command -dcsc (or --delete-closing-side-comments) reverses this process and removes these comments.
Several commands are available to modify the behavior of these two basic commands, -csc and -dcsc:
n
is the minimum number of lines that a block must have in
order for a closing side comment to be added. The default value is
n=6
. To illustrate, here is the above block processed with
-csci=2 -csc
:
sub foo { if ( !defined( $_[0] ) ) { print("Hello, World\n"); } ## end if ( !defined( $_[0] )... else { print( $_[0], "\n" ); } ## end else } ## end sub foo
Now the if
and else
blocks are commented. However, now this has
become very cluttered.
## end
. This string will be added to
closing side comments, and it will also be used to recognize them in
order to update, delete, and format them. Any comment identified as a
closing side comment will be placed just a single space to the right of
its closing brace.
string
is a list of block types to be tagged with closing side
comments. By default, all code block types preceded by a keyword or
label (such as if
, sub
, and so on) will be tagged. The -cscl
command changes the default list to be any selected block types. To
request that a block with a label be included, include a bare colon,
:
, in the list of block types. For example, the following command
requests that only sub
's, labels, BEGIN
, and END
blocks be
affected by any -csc or -dcsc operation:
-cscl="sub : BEGIN END"
if
block, is
whatever lies between the keyword introducing the block, such as if
,
and the opening brace. Since this might be too much text for a side
comment, there needs to be a limit, and that is the purpose of this
parameter. The default value is n=20
, meaning that no additional
tokens will be appended to this text after its length reaches 20
characters. Omitted text is indicated with ...
. (Tokens, including
sub names, are never truncated, however, so actual lengths may exceed
this). To illustrate, in the above example, the appended text of the
first block is ( !defined( $_[0] )...
. The existing limit of
n=20
caused this text to be truncated, as indicated by the ...
.
Important Notes on Closing Side Comments:
## end
to be ## End
, since the test is
case sensitive. You may also want to use the -ssc flag to keep these
modified closing side comments spaced the same as actual closing side comments.
##
by default, which will be treated slightly differently from other
block comments. They effectively behave as if they had glue along their
left and top edges, because they stick to the left edge and previous line
when there is no blank spaces in those places. This option is
particularly useful for controlling how commented code is displayed.
##
by
default, will be treated specially.
Comments so identified are treated as follows:
For example, assuming @month_of_year
is
left-adjusted:
@month_of_year = ( # -sbc (default) 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', ## 'Dec', 'Nov' 'Nov', 'Dec');
Without this convention, the above code would become
@month_of_year = ( # -nsbc 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
## 'Dec', 'Nov' 'Nov', 'Dec' );
which is not as clear. The default is to use -sbc. This may be deactivated with -nsbc.
##
,
corresponding to -sbcp=##
. The first character must be a #
symbol, since this must only match comments. As a simple example, to
identify all comments as static block comments, one would use -sbcp=#
.
Please note that -sbcp merely defines the pattern used to identify static block comments; it will not be used unless the switch -sbc is set. Also, please be aware that this string is used in a perl regular expression which identifies these comments, so it must enable a valid regular expression to be formed.
##
by default, will be be spaced only a single space from previous
character, and it will not be vertically aligned with other side comments.
The default is -nssc.
##
,
corresponding to -sscp=##
.
Please note that -sscp merely defines the pattern used to identify static side comments; it will not be used unless the switch -ssc is set. Also, note that this string is used in a perl regular expression which identifies these comments, so it must enable a valid regular expression to be formed.
else
and elsif
are
follow immediately after the curly brace closing the previous block.
The default is not to use cuddled elses, and is indicated with the flag
-nce or --nocuddled-else. Here is a comparison of the
alternatives:
if ($task) { yyy(); } else { # -ce zzz(); }
if ($task) { yyy(); } else { # -nce (default) zzz(); }
if ( $input_file eq '-' ) # -bl { important_function(); }
This flag applies to all structural blocks, including sub's (unless the -sbl flag is set -- see next item).
The default style, -nbl, places an opening brace on the same line as the keyword introducing it. For example,
if ( $input_file eq '-' ) { # -nbl (default)
perltidy -sbl
produces this result:
sub foo { if (!defined($_[0])) { print("Hello, World\n"); } else { print($_[0], "\n"); } }
This flag is negated with -nsbl. If -sbl is not specified, the value of -bl is used.
For example,
if ( $input_file eq '-' ) # -bli { important_function(); }
if ( $bigwasteofspace1 && $bigwasteofspace2 || $bigwasteofspace3 && $bigwasteofspace4 ) { big_waste_of_time(); }
To force the opening brace to always be on the right, use the -bar flag. In this case, the above example becomes
if ( $bigwasteofspace1 && $bigwasteofspace2 || $bigwasteofspace3 && $bigwasteofspace4 ) { big_waste_of_time(); }
A conflict occurs if both -bl and -bar are specified.
This flag does not prevent perltidy from eliminating existing line breaks; see -freeze-newlines to completely prevent changes to line break points.
-wba=s or --want-break-after=s, and
-wbb=s or --want-break-before=s.
These parameters are each followed by a quoted string, s, containing a list of token types (separated only by spaces). No more than one of each of these parameters should be specified, because repeating a command-line parameter always overwrites the previous one before perltidy ever sees it.
By default, perltidy breaks after these token types: % + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=
And perltidy breaks before these token types by default: . << >> -> && ||
To illustrate, to cause a break after a concatenation operator, '.'
,
rather than before it, the command line would be
-wba="."
As another example, the following command would cause a break before
math operators '+'
, '-'
, '/'
, and '*'
:
-wbb="+ - / *"
These commands should work well for most of the token types that perltidy uses (use --dump-token-types for a list). However, for a few token types there may be conflicts with hardwired logic which cause unexpected results. An example is the comma, which is hardwired to go at the end of lines in certain cases. Hopefully, this restriction will be removed in the future. Another example is curly braces, which should be controlled with the parameter bl provided for that purpose.
Blank lines can improve the readability of a script if they are carefully placed. Perltidy has several commands for controlling the insertion, retention, and removal of blank lines.
This is the default. The intention of this option is to introduce some space within dense coding. This is negated with -nbbb or --noblanks-before-blocks.
A style refers to a convenient collection of existing parameters.
-lp -bl -noll -pt=2 -bt=2 -sbt=2 -icp
The command -dp or --delete-pod will remove all pod documentation (but not comments).
Two commands which remove comments (but not pod) are: -dbc or --delete-block-comments and -dsc or --delete-side-comments. (Hanging side comments will be deleted with block comments here.)
The negatives of these commands also work, and are the defaults. When block comments are deleted, any leading 'hash-bang' will be retained. Also, if the -x flag is used, any system commands before a leading hash-bang will be retained (even if they are in the form of comments).
The command -tac or --tee-all-comments will write all comments and all pod documentation.
The command -tp or --tee-pod will write all pod documentation (but not comments).
The commands which write comments (but not pod) are: -tbc or --tee-block-comments and -tsc or --tee-side-comments. (Hanging side comments will be written with block comments here.)
The negatives of these commands also work, and are the defaults.
This file is free format, and 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 -se # errors to standard error output -w # show all warnings -bl # braces on new lines -pt=0 # parens not tight at all -bt=0 # braces not tight -sbt=0 # square brackets not tight
The parameters in the .perltidyrc file are installed first, so any parameters given on the command line will have priority over them.
To avoid confusion, perltidy ignores any command in the .perltidyrc file which would cause some kind of dump and an exit. These are:
-h -v -ddf -dln -dop -dsn -dtt -dwls -dwrs -ss
There are several options may be helpful in debugging a .perltidyrc file:
newword { -opt1 -opt2 }
where newword is the abbreviation, and opt1, etc, are existing parameters or other abbreviations. The main syntax requirement is that the new abbreviation must begin on a new line. Space before and after the curly braces is optional. For a specific example, the following line
airy {-bl -pt=0 -bt=0 -sbt=0}
could be placed in a .perltidyrc file, and then invoked at will with
perltidy -airy somefile.pl
(Either -airy
or --airy
may be used).
#!...perl
),
you must use the -x flag to tell perltidy not to parse and format any
lines before the ``hash-bang'' line. This option also invokes perl with a
-x flag when checking the syntax. This option was originally added to
allow perltidy to parse interactive VMS scripts, but it should be used
for any script which is normally invoked with perl -x
.
There are two ways to control this formatting. The first is with the use of comments or empty lines. If there are any comments or blank lines between the opening and closing structural brace, parenthesis, or bracket containing the list, then the original line breaks will be used for the entire list instead.
The second is with the parameter --mft=n or --maximum-fields-per-table=n. The default value for n is a large number, 40. If the computed number of fields for any table exceeds n, then it will be reduced to n. While this value should probably be left unchanged as a general rule, it might be used on a small section of code to force a list to have a particular number of fields per line, and then a single comment could be introduced somewhere to freeze the formatting in future applications of perltidy, like this:
# perltidy -mft=2 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
Vertical alignment refers to lining up similar tokens vertically, like this:
my $lines = 0; # checksum: #lines my $bytes = 0; # checksum: #bytes my $sum = 0; # checksum: system V sum
Once the perltidy vertical aligner ``locks on'' to a pattern, such as defined by the ``='' and ``#'' in the above example, it retains the pattern for as long as possible. However, a blank line or full-line comment will cause it to forget the pattern and start looking for another. Thus, a single blank line can be introduced to force the aligner to stop aligning when it is undesirable.
perltidy --mangle myfile.pl -st | perltidy -o myfile.pl.new
This will form the maximum possible number of one-line blocks (see next section), and can sometimes help clean up a badly formatted script.
A similar technique can be used with --extrude instead of --mangle to make the minimum number of one-line blocks.
Another use for --mangle is to combine it with -dac to reduce the file size of a perl script.
if ($x > 0) { $y = 1 / $x }
where the contents within the curly braces is short enough to fit on a single line.
With few exceptions, Perltidy retains existing one-line blocks, if it is possible within the line-length constraint, but it does not attempt to form new ones. In other words, Perltidy will try to follow the one-line block style of the input file.
If an existing one-line block is longer than the maximum line length, however, it will be broken into multiple lines. When this happens, perltidy checks for and adds any optional terminating semicolon (unless the -nasc option is used) if the block is a code block.
The main exception is that Perltidy will attempt to form new one-line
blocks following the keywords map
, eval
, and sort
, because
these code blocks are often small and most clearly displayed in a single
line.
Occasionally it is helpful to introduce line breaks in lists containing a '=>' symbol, which is sometimes called a ``comma-arrow''. To force perltidy to introduce breaks in a one-line block containing comma arrows, use the --break-after-comma-arrows, or -baa, flag. For example, given the following single line, Perltidy will not add any line breaks:
bless { B => $B, Root => $Root } => $package; -nbaa (default)
To introduce breaks to show the structure, use -baa:
bless { -baa B => $B, Root => $Root } => $package;
One-line block rules can conflict with the cuddled-else option. When the cuddled-else option is used, perltidy retains existing one-line blocks, even if they do not obey cuddled-else formatting.
Occasionally, when one-line blocks get broken because they exceed the available line length, the formatting will violate the requested brace style. If this happens, reformatting the script a second time should correct the problem.
--dump-defaults or -ddf will write the default option set to standard output and quit
--dump-options or -dop will write current option set to standard output and quit.
--dump-long-names or -dln will write all command line long names (passed to Get_options) to standard output and quit.
--dump-short-names or -dsn will write all command line short names to standard output and quit.
--dump-token-types or -dtt will write a list of all token types to standard output and quit.
--dump-want-left-space or -dwls will write the hash %want_left_space to standard output and quit. See the section on controlling whitespace around tokens.
--dump-want-right-space or -dwrs will write the hash %want_right_space to standard output and quit. See the section on controlling whitespace around tokens.
-DEBUG will write a file with extension .DEBUG for each input file showing the tokenization of all lines of code.
If the AutoLoader module is used, perltidy will continue formatting code after seeing an __END__ line. Use --nolook-for-autoloader, or -nlal, to deactivate this feature.
Likewise, if the SelfLoader module is used, perltidy will continue formatting code after seeing a __DATA__ line. Use --nolook-for-selfloader, or -nlsl, to deactivate this feature.
perltidy -html somefile.pl
will produce a syntax-colored html file named somefile.pl.html which may be viewed with a browser.
Documentation for this option has been moved to a separate man page, perl2web(1).
The following list shows all short parameter names which allow a prefix 'n' to produce the negated form:
D anl asc aws bbb bbc bbs bli baa syn ce csc dac dbc dcsc dnl dws dp dsm dsc ddf dln dop dsn dtt dwls dwrs f fll hsc html ibc icb icp lp log lal x lsl bl sbl okw ola oll pvl q opt sbc sfs ssc sts se st sob t tac tbc tp tsc tqw w
Equivalently, the prefix 'no' on the corresponding long names may be used.
The main current limitation is that perltidy does not scan modules included with 'use' statements. This makes it necessary to guess the context of any bare words introduced by such modules. Perltidy has good guessing algorithms, but they are not infallible. When it must guess, it leaves a message in the log file.
If you encounter a bug, please report it.
qw
quotes.
Perltidy does not in any way modify the contents of here documents or
quoted text, even if they contain source code. (You could, however,
reformat them separately). Perltidy does not format 'format' sections
in any way. And, of course, it does not modify pod documents.
When standard output and syntax checking are used, a temporary copy of the output file will be created in the current working directory called perltidy.TMPO. It will be removed when perltidy finishes.
perl2web(1), perlstyle(1)
This man page documents perltidy version 20011231.
Steven L. Hancock email: perltidy at users.sourceforge.net http://perltidy.sourceforge.net
Copyright (c) 2000, 2001 by Steven L. Hancock
This package is free software; you can redistribute it and/or modify it under the terms of the ``GNU General Public License''.
Please refer to the file ``COPYING'' for details.
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the ``GNU General Public License'' for more details.