]> git.donarmstrong.com Git - perltidy.git/blob - docs/perltidy.1
* upgrade to the 20060614 release
[perltidy.git] / docs / perltidy.1
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "PERLTIDY 1"
132 .TH PERLTIDY 1 "2006-06-13" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 perltidy \- a perl script indenter and reformatter
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 5
138 \&    perltidy [ options ] file1 file2 file3 ...
139 \&            (output goes to file1.tdy, file2.tdy, file3.tdy, ...)
140 \&    perltidy [ options ] file1 \-o outfile
141 \&    perltidy [ options ] file1 \-st >outfile
142 \&    perltidy [ options ] <infile >outfile
143 .Ve
144 .SH "DESCRIPTION"
145 .IX Header "DESCRIPTION"
146 Perltidy reads a perl script and writes an indented, reformatted script.
147 .PP
148 Many users will find enough information in \*(L"\s-1EXAMPLES\s0\*(R" to get 
149 started.  New users may benefit from the short tutorial 
150 which can be found at
151 http://perltidy.sourceforge.net/tutorial.html
152 .PP
153 A convenient aid to systematically defining a set of style parameters
154 can be found at
155 http://perltidy.sourceforge.net/stylekey.html
156 .PP
157 Perltidy can produce output on either of two modes, depending on the
158 existence of an \fB\-html\fR flag.  Without this flag, the output is passed
159 through a formatter.  The default formatting tries to follow the
160 recommendations in \fIperlstyle\fR\|(1), but it can be controlled in detail with
161 numerous input parameters, which are described in \*(L"\s-1FORMATTING\s0 \s-1OPTIONS\s0\*(R".  
162 .PP
163 When the \fB\-html\fR flag is given, the output is passed through an \s-1HTML\s0
164 formatter which is described in \*(L"\s-1HTML\s0 \s-1OPTIONS\s0\*(R".  
165 .SH "EXAMPLES"
166 .IX Header "EXAMPLES"
167 .Vb 1
168 \&  perltidy somefile.pl
169 .Ve
170 .PP
171 This will produce a file \fIsomefile.pl.tdy\fR containing the script reformatted
172 using the default options, which approximate the style suggested in 
173 \&\fIperlstyle\fR\|(1).  Perltidy never changes the input file.
174 .PP
175 .Vb 1
176 \&  perltidy *.pl
177 .Ve
178 .PP
179 Execute perltidy on all \fI.pl\fR files in the current directory with the
180 default options.  The output will be in files with an appended \fI.tdy\fR
181 extension.  For any file with an error, there will be a file with extension
182 \&\fI.ERR\fR.
183 .PP
184 .Vb 1
185 \&  perltidy \-b file1.pl file2.pl
186 .Ve
187 .PP
188 Modify \fIfile1.pl\fR and \fIfile1.pl\fR in place, and backup the originals to
189 \&\fIfile1.pl.bak\fR and \fIfile2.pl.bak\fR.  If \fIfile1.pl.bak\fR and/or \fIfile2.pl.bak\fR
190 already exist, they will be overwritten.
191 .PP
192 .Vb 1
193 \&  perltidy \-gnu somefile.pl
194 .Ve
195 .PP
196 Execute perltidy on file \fIsomefile.pl\fR with a style which approximates the
197 \&\s-1GNU\s0 Coding Standards for C programs.  The output will be \fIsomefile.pl.tdy\fR.
198 .PP
199 .Vb 1
200 \&  perltidy \-i=3 somefile.pl
201 .Ve
202 .PP
203 Execute perltidy on file \fIsomefile.pl\fR, with 3 columns for each level of
204 indentation (\fB\-i=3\fR) instead of the default 4 columns.  There will not be any
205 tabs in the reformatted script, except for any which already exist in comments,
206 pod documents, quotes, and here documents.  Output will be \fIsomefile.pl.tdy\fR. 
207 .PP
208 .Vb 1
209 \&  perltidy \-i=3 \-et=8 somefile.pl
210 .Ve
211 .PP
212 Same as the previous example, except that leading whitespace will
213 be entabbed with one tab character per 8 spaces.
214 .PP
215 .Vb 1
216 \&  perltidy \-ce \-l=72 somefile.pl
217 .Ve
218 .PP
219 Execute perltidy on file \fIsomefile.pl\fR with all defaults except use \*(L"cuddled
220 elses\*(R" (\fB\-ce\fR) and a maximum line length of 72 columns (\fB\-l=72\fR) instead of
221 the default 80 columns.  
222 .PP
223 .Vb 1
224 \&  perltidy \-g somefile.pl
225 .Ve
226 .PP
227 Execute perltidy on file \fIsomefile.pl\fR and save a log file \fIsomefile.pl.LOG\fR
228 which shows the nesting of braces, parentheses, and square brackets at
229 the start of every line.
230 .PP
231 .Vb 1
232 \&  perltidy \-html somefile.pl
233 .Ve
234 .PP
235 This will produce a file \fIsomefile.pl.html\fR containing the script with
236 html markup.  The output file will contain an embedded style sheet in
237 the <\s-1HEAD\s0> section which may be edited to change the appearance.
238 .PP
239 .Vb 1
240 \&  perltidy \-html \-css=mystyle.css somefile.pl
241 .Ve
242 .PP
243 This will produce a file \fIsomefile.pl.html\fR containing the script with
244 html markup.  This output file will contain a link to a separate style
245 sheet file \fImystyle.css\fR.  If the file \fImystyle.css\fR does not exist,
246 it will be created.  If it exists, it will not be overwritten.
247 .PP
248 .Vb 1
249 \&  perltidy \-html \-pre somefile.pl
250 .Ve
251 .PP
252 Write an html snippet with only the \s-1PRE\s0 section to \fIsomefile.pl.html\fR.
253 This is useful when code snippets are being formatted for inclusion in a
254 larger web page.  No style sheet will be written in this case.  
255 .PP
256 .Vb 1
257 \&  perltidy \-html \-ss >mystyle.css
258 .Ve
259 .PP
260 Write a style sheet to \fImystyle.css\fR and exit.
261 .PP
262 .Vb 1
263 \&  perltidy \-html \-frm mymodule.pm
264 .Ve
265 .PP
266 Write html with a frame holding a table of contents and the source code.  The
267 output files will be \fImymodule.pm.html\fR (the frame), \fImymodule.pm.toc.html\fR
268 (the table of contents), and \fImymodule.pm.src.html\fR (the source code).
269 .SH "OPTIONS \- OVERVIEW"
270 .IX Header "OPTIONS - OVERVIEW"
271 The entire command line is scanned for options, and they are processed
272 before any files are processed.  As a result, it does not matter
273 whether flags are before or after any filenames.  However, the relative
274 order of parameters is important, with later parameters overriding the
275 values of earlier parameters.
276 .PP
277 For each parameter, there is a long name and a short name.  The short
278 names are convenient for keyboard input, while the long names are
279 self-documenting and therefore useful in scripts.  It is customary to
280 use two leading dashes for long names, but one may be used.
281 .PP
282 Most parameters which serve as on/off flags can be negated with a
283 leading \*(L"n\*(R" (for the short name) or a leading \*(L"no\*(R" or \*(L"no\-\*(R" (for the
284 long name).  For example, the flag to outdent long quotes is is \fB\-olq\fR
285 or \fB\-\-outdent\-long\-quotes\fR.  The flag to skip this is \fB\-nolq\fR
286 or \fB\-\-nooutdent\-long\-quotes\fR or \fB\-\-no\-outdent\-long\-quotes\fR.
287 .PP
288 Options may not be bundled together.  In other words, options \fB\-q\fR and
289 \&\fB\-g\fR may \s-1NOT\s0 be entered as \fB\-qg\fR.
290 .PP
291 Option names may be terminated early as long as they are uniquely identified.
292 For example, instead of \fB\-\-dump\-token\-types\fR, it would be sufficient to enter
293 \&\fB\-\-dump\-tok\fR, or even \fB\-\-dump\-t\fR, to uniquely identify this command.
294 .Sh "I/O control"
295 .IX Subsection "I/O control"
296 The following parameters concern the files which are read and written.
297 .IP "\fB\-h\fR,    \fB\-\-help\fR" 4
298 .IX Item "-h,    --help"
299 Show summary of usage and exit.
300 .IP "\fB\-o\fR=filename,    \fB\-\-outfile\fR=filename" 4
301 .IX Item "-o=filename,    --outfile=filename"
302 Name of the output file (only if a single input file is being
303 processed).  If no output file is specified, and output is not
304 redirected to the standard output, the output will go to \fIfilename.tdy\fR.
305 .IP "\fB\-st\fR,    \fB\-\-standard\-output\fR" 4
306 .IX Item "-st,    --standard-output"
307 Perltidy must be able to operate on an arbitrarily large number of files
308 in a single run, with each output being directed to a different output
309 file.  Obviously this would conflict with outputting to the single
310 standard output device, so a special flag, \fB\-st\fR, is required to
311 request outputting to the standard output.  For example,
312 .Sp
313 .Vb 1
314 \&  perltidy somefile.pl \-st >somefile.new.pl
315 .Ve
316 .Sp
317 This option may only be used if there is just a single input file.  
318 The default is \fB\-nst\fR or \fB\-\-nostandard\-output\fR.
319 .IP "\fB\-se\fR,    \fB\-\-standard\-error\-output\fR" 4
320 .IX Item "-se,    --standard-error-output"
321 If perltidy detects an error when processing file \fIsomefile.pl\fR, its
322 default behavior is to write error messages to file \fIsomefile.pl.ERR\fR.
323 Use \fB\-se\fR to cause all error messages to be sent to the standard error
324 output stream instead.  This directive may be negated with \fB\-nse\fR.
325 Thus, you may place \fB\-se\fR in a \fI.perltidyrc\fR and override it when
326 desired with \fB\-nse\fR on the command line.
327 .IP "\fB\-oext\fR=ext,    \fB\-\-output\-file\-extension\fR=ext" 4
328 .IX Item "-oext=ext,    --output-file-extension=ext"
329 Change the extension of the output file to be \fIext\fR instead of the
330 default \fItdy\fR (or \fIhtml\fR in case the \-\fB\-html\fR option is used).
331 See \*(L"Specifying File Extensions\*(R".
332 .IP "\fB\-opath\fR=path,    \fB\-\-output\-path\fR=path" 4
333 .IX Item "-opath=path,    --output-path=path"
334 When perltidy creates a filename for an output file, by default it merely
335 appends an extension to the path and basename of the input file.  This
336 parameter causes the path to be changed to \fIpath\fR instead.
337 .Sp
338 The path should end in a valid path separator character, but perltidy will try
339 to add one if it is missing.
340 .Sp
341 For example
342 .Sp
343 .Vb 1
344 \& perltidy somefile.pl \-opath=/tmp/
345 .Ve
346 .Sp
347 will produce \fI/tmp/somefile.pl.tdy\fR.  Otherwise, \fIsomefile.pl.tdy\fR will
348 appear in whatever directory contains \fIsomefile.pl\fR.
349 .Sp
350 If the path contains spaces, it should be placed in quotes.
351 .Sp
352 This parameter will be ignored if output is being directed to standard output,
353 or if it is being specified explicitly with the \fB\-o=s\fR parameter.
354 .IP "\fB\-b\fR,    \fB\-\-backup\-and\-modify\-in\-place\fR" 4
355 .IX Item "-b,    --backup-and-modify-in-place"
356 Modify the input file or files in-place and save the original with the
357 extension \fI.bak\fR.  Any existing \fI.bak\fR file will be deleted.  See next item
358 for changing the default backup extension.  
359 .Sp
360 A \fB\-b\fR flag will be ignored if input is from standard input, or
361 if the \fB\-html\fR flag is set. 
362 .IP "\fB\-bext\fR=ext,    \fB\-\-backup\-file\-extension\fR=ext" 4
363 .IX Item "-bext=ext,    --backup-file-extension=ext"
364 Change the extension of the backup file to be something other than the
365 default \fI.bak\fR.  See \*(L"Specifying File Extensions\*(R".
366 .IP "\fB\-w\fR,    \fB\-\-warning\-output\fR" 4
367 .IX Item "-w,    --warning-output"
368 Setting \fB\-w\fR causes any non-critical warning
369 messages to be reported as errors.  These include messages
370 about possible pod problems, possibly bad starting indentation level,
371 and cautions about indirect object usage.  The default, \fB\-nw\fR or
372 \&\fB\-\-nowarning\-output\fR, is not to include these warnings.
373 .IP "\fB\-q\fR,    \fB\-\-quiet\fR" 4
374 .IX Item "-q,    --quiet"
375 Deactivate error messages and syntax checking (for running under
376 an editor). 
377 .Sp
378 For example, if you use a vi-style editor, such as vim, you may execute
379 perltidy as a filter from within the editor using something like
380 .Sp
381 .Vb 1
382 \& :n1,n2!perltidy \-q
383 .Ve
384 .Sp
385 where \f(CW\*(C`n1,n2\*(C'\fR represents the selected text.  Without the \fB\-q\fR flag,
386 any error message may mess up your screen, so be prepared to use your
387 \&\*(L"undo\*(R" key.
388 .IP "\fB\-log\fR,    \fB\-\-logfile\fR" 4
389 .IX Item "-log,    --logfile"
390 Save the \fI.LOG\fR file, which has many useful diagnostics.  Perltidy always
391 creates a \fI.LOG\fR file, but by default it is deleted unless a program bug is
392 suspected.  Setting the \fB\-log\fR flag forces the log file to be saved.
393 .IP "\fB\-g=n\fR, \fB\-\-logfile\-gap=n\fR" 4
394 .IX Item "-g=n, --logfile-gap=n"
395 Set maximum interval between input code lines in the logfile.  This purpose of
396 this flag is to assist in debugging nesting errors.  The value of \f(CW\*(C`n\*(C'\fR is
397 optional.  If you set the flag \fB\-g\fR without the value of \f(CW\*(C`n\*(C'\fR, it will be
398 taken to be 1, meaning that every line will be written to the log file.  This
399 can be helpful if you are looking for a brace, paren, or bracket nesting error. 
400 .Sp
401 Setting \fB\-g\fR also causes the logfile to be saved, so it is not necessary to
402 also include \fB\-log\fR. 
403 .Sp
404 If no \fB\-g\fR flag is given, a value of 50 will be used, meaning that at least
405 every 50th line will be recorded in the logfile.  This helps prevent
406 excessively long log files.  
407 .Sp
408 Setting a negative value of \f(CW\*(C`n\*(C'\fR is the same as not setting \fB\-g\fR at all.
409 .IP "\fB\-npro\fR  \fB\-\-noprofile\fR" 4
410 .IX Item "-npro  --noprofile"
411 Ignore any \fI.perltidyrc\fR command file.  Normally, perltidy looks first in
412 your current directory for a \fI.perltidyrc\fR file of parameters.  (The format
413 is described below).  If it finds one, it applies those options to the
414 initial default values, and then it applies any that have been defined
415 on the command line.  If no \fI.perltidyrc\fR file is found, it looks for one
416 in your home directory.
417 .Sp
418 If you set the \fB\-npro\fR flag, perltidy will not look for this file.
419 .IP "\fB\-pro=filename\fR or  \fB\-\-profile=filename\fR" 4
420 .IX Item "-pro=filename or  --profile=filename"
421 To simplify testing and switching .perltidyrc files, this command may be
422 used to specify a configuration file which will override the default
423 name of .perltidyrc.  There must not be a space on either side of the
424 \&'=' sign.  For example, the line
425 .Sp
426 .Vb 1
427 \&   perltidy \-pro=testcfg
428 .Ve
429 .Sp
430 would cause file \fItestcfg\fR to be used instead of the 
431 default \fI.perltidyrc\fR.
432 .IP "\fB\-opt\fR,   \fB\-\-show\-options\fR" 4
433 .IX Item "-opt,   --show-options"
434 Write a list of all options used to the \fI.LOG\fR file.  
435 Please see \fB\-\-dump\-options\fR for a simpler way to do this.
436 .IP "\fB\-f\fR,   \fB\-\-force\-read\-binary\fR" 4
437 .IX Item "-f,   --force-read-binary"
438 Force perltidy to process binary files.  To avoid producing excessive
439 error messages, perltidy skips files identified by the system as non\-text.
440 However, valid perl scripts containing binary data may sometimes be identified
441 as non\-text, and this flag forces perltidy to process them.
442 .SH "FORMATTING OPTIONS"
443 .IX Header "FORMATTING OPTIONS"
444 .Sh "Basic Options"
445 .IX Subsection "Basic Options"
446 .IP "\fB\-l=n\fR, \fB\-\-maximum\-line\-length=n\fR" 4
447 .IX Item "-l=n, --maximum-line-length=n"
448 The default maximum line length is n=80 characters.  Perltidy will try
449 to find line break points to keep lines below this length. However, long
450 quotes and side comments may cause lines to exceed this length. 
451 Setting \fB\-l=0\fR is equivalent to setting \fB\-l=(a large number)\fR. 
452 .IP "\fB\-i=n\fR,  \fB\-\-indent\-columns=n\fR" 4
453 .IX Item "-i=n,  --indent-columns=n"
454 Use n columns per indentation level (default n=4).
455 .IP "tabs" 4
456 .IX Item "tabs"
457 Using tab characters will almost certainly lead to future portability
458 and maintenance problems, so the default and recommendation is not to
459 use them.  For those who prefer tabs, however, there are two different
460 options.  
461 .Sp
462 Except for possibly introducing tab indentation characters, as outlined
463 below, perltidy does not introduce any tab characters into your file,
464 and it removes any tabs from the code (unless requested not to do so
465 with \fB\-fws\fR).  If you have any tabs in your comments, quotes, or
466 here\-documents, they will remain.
467 .RS 4
468 .IP "\fB\-et=n\fR,   \fB\-\-entab\-leading\-whitespace\fR" 4
469 .IX Item "-et=n,   --entab-leading-whitespace"
470 This flag causes each \fBn\fR initial space characters to be replaced by
471 one tab character.  Note that the integer \fBn\fR is completely independent
472 of the integer specified for indentation parameter, \fB\-i=n\fR.
473 .IP "\fB\-t\fR,   \fB\-\-tabs\fR" 4
474 .IX Item "-t,   --tabs"
475 This flag causes one leading tab character to be inserted for each level
476 of indentation.  Certain other features are incompatible with this
477 option, and if these options are also given, then a warning message will
478 be issued and this flag will be unset.  One example is the \fB\-lp\fR
479 option.
480 .RE
481 .RS 4
482 .RE
483 .IP "\fB\-syn\fR,   \fB\-\-check\-syntax\fR" 4
484 .IX Item "-syn,   --check-syntax"
485 This flag causes perltidy to run \f(CW\*(C`perl \-c \-T\*(C'\fR to check syntax of input
486 and output.  (To change the flags passed to perl, see the next
487 item, \fB\-pscf\fR).  The results are written to the \fI.LOG\fR file, which
488 will be saved if an error is detected in the output script.  The output
489 script is not checked if the input script has a syntax error.  Perltidy
490 does its own checking, but this option employs perl to get a \*(L"second
491 opinion\*(R".
492 .Sp
493 If perl reports errors in the input file, they will not be reported in
494 the error output unless the \fB\-\-warning\-output\fR flag is given. 
495 .Sp
496 The default is \fBnot\fR to do this type of syntax checking (although
497 perltidy will still do as much self-checking as possible).  The reason
498 is that it causes all code in \s-1BEGIN\s0 blocks to be executed, for all
499 modules being used, and this opens the door to security issues and
500 infinite loops when running perltidy.
501 .IP "\fB\-pscf=s\fR, \fB\-perl\-syntax\-check\-flags=s\fR" 4
502 .IX Item "-pscf=s, -perl-syntax-check-flags=s"
503 When perl is invoked to check syntax, the normal flags are \f(CW\*(C`\-c \-T\*(C'\fR.  In
504 addition, if the \fB\-x\fR flag is given to perltidy, then perl will also be
505 passed a \fB\-x\fR flag.  It should not normally be necessary to change
506 these flags, but it can be done with the \fB\-pscf=s\fR flag.  For example,
507 if the taint flag, \f(CW\*(C`\-T\*(C'\fR, is not wanted, the flag could be set to be just
508 \&\fB\-pscf=\-c\fR.  
509 .Sp
510 Perltidy will pass your string to perl with the exception that it will
511 add a \fB\-c\fR and \fB\-x\fR if appropriate.  The \fI.LOG\fR file will show
512 exactly what flags were passed to perl.
513 .IP "\fB\-io\fR,   \fB\-\-indent\-only\fR" 4
514 .IX Item "-io,   --indent-only"
515 This flag is used to deactivate all formatting and line break changes.
516 When it is in effect, the only change to the script will be indentation.
517 And any flags controlling whitespace and newlines will be ignored.  You
518 might want to use this if you are perfectly happy with your whitespace
519 and line breaks, and merely want perltidy to handle the indentation.
520 (This also speeds up perltidy by well over a factor of two, so it might be
521 useful when perltidy is merely being used to help find a brace error in
522 a large script).
523 .Sp
524 Setting this flag is equivalent to setting \fB\-\-freeze\-newlines\fR and
525 \&\fB\-\-freeze\-whitespace\fR.
526 .IP "\fB\-ole=s\fR,  \fB\-\-output\-line\-ending=s\fR" 4
527 .IX Item "-ole=s,  --output-line-ending=s"
528 where s=\f(CW\*(C`win\*(C'\fR, \f(CW\*(C`dos\*(C'\fR, \f(CW\*(C`unix\*(C'\fR, or \f(CW\*(C`mac\*(C'\fR.  This flag tells perltidy
529 to output line endings for a specific system.  Normally,
530 perltidy writes files with the line separator character of the host
531 system.  The \f(CW\*(C`win\*(C'\fR and \f(CW\*(C`dos\*(C'\fR flags have an identical result.
532 \&\fB\s-1NOTE\s0\fR: This only works under unix-like systems and is ignored under
533 other systems.
534 .IP "\fB\-ple\fR,  \fB\-\-preserve\-line\-endings\fR" 4
535 .IX Item "-ple,  --preserve-line-endings"
536 This flag tells perltidy to write its output files with the same line
537 endings as the input file, if possible.  It should work for
538 \&\fBdos\fR, \fBunix\fR, and \fBmac\fR line endings.  It will only work if perltidy
539 input comes from a filename (rather than stdin, for example).  If
540 perltidy has trouble determining the input file line ending, it will
541 revert to the default behavior of using the line ending of the host system.
542 \&\fB\s-1NOTE\s0\fR: This only works under unix-like systems and is ignored under
543 other systems.
544 .Sh "Code Indentation Control"
545 .IX Subsection "Code Indentation Control"
546 .IP "\fB\-ci=n\fR, \fB\-\-continuation\-indentation=n\fR" 4
547 .IX Item "-ci=n, --continuation-indentation=n"
548 Continuation indentation is extra indentation spaces applied when
549 a long line is broken.  The default is n=2, illustrated here:
550 .Sp
551 .Vb 2
552 \& my $level =   # \-ci=2      
553 \&   ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
554 .Ve
555 .Sp
556 The same example, with n=0, is a little harder to read:
557 .Sp
558 .Vb 2
559 \& my $level =   # \-ci=0    
560 \& ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
561 .Ve
562 .Sp
563 The value given to \fB\-ci\fR is also used by some commands when a small
564 space is required.  Examples are commands for outdenting labels,
565 \&\fB\-ola\fR, and control keywords, \fB\-okw\fR.  
566 .Sp
567 When default values are not used, it is suggested that the value \fBn\fR
568 given with \fB\-ci=n\fR be no more than about one-half of the number of
569 spaces assigned to a full indentation level on the \fB\-i=n\fR command.
570 .IP "\fB\-sil=n\fR \fB\-\-starting\-indentation\-level=n\fR" 4
571 .IX Item "-sil=n --starting-indentation-level=n"
572 By default, perltidy examines the input file and tries to determine the
573 starting indentation level.  While it is often zero, it may not be
574 zero for a code snippet being sent from an editing session.  If the
575 default method does not work correctly, or you want to change the
576 starting level, use \fB\-sil=n\fR, to force the starting level to be n.
577 .IP "List indentation using \fB\-lp\fR, \fB\-\-line\-up\-parentheses\fR" 4
578 .IX Item "List indentation using -lp, --line-up-parentheses"
579 By default, perltidy indents lists with 4 spaces, or whatever value
580 is specified with \fB\-i=n\fR.  Here is a small list formatted in this way:
581 .Sp
582 .Vb 5
583 \&    # perltidy (default)
584 \&    @month_of_year = (
585 \&        'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
586 \&        'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
587 \&    );
588 .Ve
589 .Sp
590 Use the \fB\-lp\fR flag to add extra indentation to cause the data to begin
591 past the opening parentheses of a sub call or list, or opening square
592 bracket of an anonymous array, or opening curly brace of an anonymous
593 hash.  With this option, the above list would become:
594 .Sp
595 .Vb 5
596 \&    # perltidy \-lp
597 \&    @month_of_year = (
598 \&                       'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
599 \&                       'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
600 \&    );
601 .Ve
602 .Sp
603 If the available line length (see \fB\-l=n\fR ) does not permit this much 
604 space, perltidy will use less.   For alternate placement of the
605 closing paren, see the next section.
606 .Sp
607 This option has no effect on code \s-1BLOCKS\s0, such as if/then/else blocks,
608 which always use whatever is specified with \fB\-i=n\fR.  Also, the
609 existence of line breaks and/or block comments between the opening and
610 closing parens may cause perltidy to temporarily revert to its default
611 method.
612 .Sp
613 Note: The \fB\-lp\fR option may not be used together with the \fB\-t\fR tabs option.
614 It may, however, be used with the \fB\-et=n\fR tab method.
615 .Sp
616 In addition, any parameter which significantly restricts the ability of
617 perltidy to choose newlines will conflict with \fB\-lp\fR and will cause
618 \&\fB\-lp\fR to be deactivated.  These include \fB\-io\fR, \fB\-fnl\fR, \fB\-nanl\fR, and
619 \&\fB\-ndnl\fR.  The reason is that the \fB\-lp\fR indentation style can require
620 the careful coordination of an arbitrary number of break points in
621 hierarchical lists, and these flags may prevent that.
622 .IP "\fB\-cti=n\fR, \fB\-\-closing\-token\-indentation\fR" 4
623 .IX Item "-cti=n, --closing-token-indentation"
624 The \fB\-cti=n\fR flag controls the indentation of a line beginning with 
625 a \f(CW\*(C`)\*(C'\fR, \f(CW\*(C`]\*(C'\fR, or a non-block \f(CW\*(C`}\*(C'\fR.  Such a line receives:
626 .Sp
627 .Vb 6
628 \& \-cti = 0 no extra indentation (default)
629 \& \-cti = 1 extra indentation such that the closing token
630 \&        aligns with its opening token.
631 \& \-cti = 2 one extra indentation level if the line looks like:
632 \&        );  or  ];  or  };
633 \& \-cti = 3 one extra indentation level always
634 .Ve
635 .Sp
636 The flags \fB\-cti=1\fR and \fB\-cti=2\fR work well with the \fB\-lp\fR flag (previous
637 section).
638 .Sp
639 .Vb 5
640 \&    # perltidy \-lp \-cti=1
641 \&    @month_of_year = (
642 \&                       'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
643 \&                       'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
644 \&                     );
645 .Ve
646 .Sp
647 .Vb 5
648 \&    # perltidy \-lp \-cti=2
649 \&    @month_of_year = (
650 \&                       'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
651 \&                       'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
652 \&                       );
653 .Ve
654 .Sp
655 These flags are merely hints to the formatter and they may not always be
656 followed.  In particular, if \-lp is not being used, the indentation for
657 \&\fBcti=1\fR is constrained to be no more than one indentation level.
658 .Sp
659 If desired, this control can be applied independently to each of the
660 closing container token types.  In fact, \fB\-cti=n\fR is merely an
661 abbreviation for \fB\-cpi=n \-csbi=n \-cbi=n\fR, where:  
662 \&\fB\-cpi\fR or \fB\-\-closing\-paren\-indentation\fR controls \fB)\fR's,
663 \&\fB\-csbi\fR or \fB\-\-closing\-square\-bracket\-indentation\fR controls \fB]\fR's, 
664 \&\fB\-cbi\fR or \fB\-\-closing\-brace\-indentation\fR controls non-block \fB}\fR's. 
665 .IP "\fB\-icp\fR, \fB\-\-indent\-closing\-paren\fR" 4
666 .IX Item "-icp, --indent-closing-paren"
667 The \fB\-icp\fR flag is equivalent to
668 \&\fB\-cti=2\fR, described in the previous section.  The \fB\-nicp\fR flag is
669 equivalent \fB\-cti=0\fR.  They are included for backwards compatability.
670 .IP "\fB\-icb\fR, \fB\-\-indent\-closing\-brace\fR" 4
671 .IX Item "-icb, --indent-closing-brace"
672 The \fB\-icb\fR option gives one extra level of indentation to a brace which
673 terminates a code block .  For example,
674 .Sp
675 .Vb 6
676 \&        if ($task) {
677 \&            yyy();
678 \&            }    # \-icb
679 \&        else {
680 \&            zzz();
681 \&            }
682 .Ve
683 .Sp
684 The default is not to do this, indicated by \fB\-nicb\fR.
685 .IP "\fB\-olq\fR, \fB\-\-outdent\-long\-quotes\fR" 4
686 .IX Item "-olq, --outdent-long-quotes"
687 When \fB\-olq\fR is set, lines which is a quoted string longer than the
688 value \fBmaximum-line-length\fR will have their indentation removed to make
689 them more readable.  This is the default.  To prevent such out\-denting,
690 use \fB\-nolq\fR or \fB\-\-nooutdent\-long\-lines\fR.
691 .IP "\fB\-oll\fR, \fB\-\-outdent\-long\-lines\fR" 4
692 .IX Item "-oll, --outdent-long-lines"
693 This command is equivalent to \fB\-\-outdent\-long\-quotes\fR and
694 \&\fB\-\-outdent\-long\-comments\fR, and it is included for compatibility with previous
695 versions of perltidy.  The negation of this also works, \fB\-noll\fR or
696 \&\fB\-\-nooutdent\-long\-lines\fR, and is equivalent to setting \fB\-nolq\fR and \fB\-nolc\fR.
697 .IP "Outdenting Labels: \fB\-ola\fR,  \fB\-\-outdent\-labels\fR" 4
698 .IX Item "Outdenting Labels: -ola,  --outdent-labels"
699 This command will cause labels to be outdented by 2 spaces (or whatever \fB\-ci\fR
700 has been set to), if possible.  This is the default.  For example:
701 .Sp
702 .Vb 6
703 \&        my $i;
704 \&      LOOP: while ( $i = <FOTOS> ) {
705 \&            chomp($i);
706 \&            next unless $i;
707 \&            fixit($i);
708 \&        }
709 .Ve
710 .Sp
711 Use \fB\-nola\fR to not outdent labels. 
712 .IP "Outdenting Keywords" 4
713 .IX Item "Outdenting Keywords"
714 .RS 4
715 .PD 0
716 .IP "\fB\-okw\fR,  \fB\-\-outdent\-keywords\fR" 4
717 .IX Item "-okw,  --outdent-keywords"
718 .PD
719 The command \fB\-okw\fR will will cause certain leading control keywords to
720 be outdented by 2 spaces (or whatever \fB\-ci\fR has been set to), if
721 possible.  By default, these keywords are \f(CW\*(C`redo\*(C'\fR, \f(CW\*(C`next\*(C'\fR, \f(CW\*(C`last\*(C'\fR,
722 \&\f(CW\*(C`goto\*(C'\fR, and \f(CW\*(C`return\*(C'\fR.  The intention is to make these control keywords
723 easier to see.  To change this list of keywords being outdented, see
724 the next section.
725 .Sp
726 For example, using \f(CW\*(C`perltidy \-okw\*(C'\fR on the previous example gives:
727 .Sp
728 .Vb 6
729 \&        my $i;
730 \&      LOOP: while ( $i = <FOTOS> ) {
731 \&            chomp($i);
732 \&          next unless $i;
733 \&            fixit($i);
734 \&        }
735 .Ve
736 .Sp
737 The default is not to do this.  
738 .IP "Specifying Outdented Keywords: \fB\-okwl=string\fR,  \fB\-\-outdent\-keyword\-list=string\fR" 4
739 .IX Item "Specifying Outdented Keywords: -okwl=string,  --outdent-keyword-list=string"
740 This command can be used to change the keywords which are outdented with
741 the \fB\-okw\fR command.  The parameter \fBstring\fR is a required list of perl
742 keywords, which should be placed in quotes if there are more than one.
743 By itself, it does not cause any outdenting to occur, so the \fB\-okw\fR
744 command is still required.
745 .Sp
746 For example, the commands \f(CW\*(C`\-okwl="next last redo goto" \-okw\*(C'\fR will cause
747 those four keywords to be outdented.  It is probably simplest to place
748 any \fB\-okwl\fR command in a \fI.perltidyrc\fR file.
749 .RE
750 .RS 4
751 .RE
752 .Sh "Whitespace Control"
753 .IX Subsection "Whitespace Control"
754 Whitespace refers to the blank space between variables, operators,
755 and other code tokens.
756 .IP "\fB\-fws\fR,  \fB\-\-freeze\-whitespace\fR" 4
757 .IX Item "-fws,  --freeze-whitespace"
758 This flag causes your original whitespace to remain unchanged, and
759 causes the rest of the whitespace commands in this section, the
760 Code Indentation section, and
761 the Comment Control section to be ignored.
762 .IP "Tightness of curly braces, parentheses, and square brackets." 4
763 .IX Item "Tightness of curly braces, parentheses, and square brackets."
764 Here the term \*(L"tightness\*(R" will mean the closeness with which
765 pairs of enclosing tokens, such as parentheses, contain the quantities
766 within.  A numerical value of 0, 1, or 2 defines the tightness, with
767 0 being least tight and 2 being most tight.  Spaces within containers
768 are always symmetric, so if there is a space after a \f(CW\*(C`(\*(C'\fR then there
769 will be a space before the corresponding \f(CW\*(C`)\*(C'\fR.
770 .Sp
771 The \fB\-pt=n\fR or \fB\-\-paren\-tightness=n\fR parameter controls the space within
772 parens.  The example below shows the effect of the three possible
773 values, 0, 1, and 2:
774 .Sp
775 .Vb 3
776 \& if ( ( my $len_tab = length( $tabstr ) ) > 0 ) {  # \-pt=0
777 \& if ( ( my $len_tab = length($tabstr) ) > 0 ) {    # \-pt=1 (default)
778 \& if ((my $len_tab = length($tabstr)) > 0) {        # \-pt=2
779 .Ve
780 .Sp
781 When n is 0, there is always a space to the right of a '(' and to the left
782 of a ')'.  For n=2 there is never a space.  For n=1, the default, there
783 is a space unless the quantity within the parens is a single token, such
784 as an identifier or quoted string.  
785 .Sp
786 Likewise, the parameter \fB\-sbt=n\fR or \fB\-\-square\-bracket\-tightness=n\fR
787 controls the space within square brackets, as illustrated below.
788 .Sp
789 .Vb 3
790 \& $width = $col[ $j + $k ] \- $col[ $j ];  # \-sbt=0
791 \& $width = $col[ $j + $k ] \- $col[$j];    # \-sbt=1 (default)
792 \& $width = $col[$j + $k] \- $col[$j];      # \-sbt=2
793 .Ve
794 .Sp
795 Curly braces which do not contain code blocks are controlled by
796 the parameter \fB\-bt=n\fR or \fB\-\-brace\-tightness=n\fR. 
797 .Sp
798 .Vb 3
799 \& $obj\->{ $parsed_sql\->{ 'table' }[0] };    # \-bt=0
800 \& $obj\->{ $parsed_sql\->{'table'}[0] };      # \-bt=1 (default)
801 \& $obj\->{$parsed_sql\->{'table'}[0]};        # \-bt=2
802 .Ve
803 .Sp
804 And finally, curly braces which contain blocks of code are controlled by the
805 parameter \fB\-bbt=n\fR or \fB\-\-block\-brace\-tightness=n\fR as illustrated in the
806 example below.   
807 .Sp
808 .Vb 3
809 \& %bf = map { $_ => \-M $_ } grep { /\e.deb$/ } dirents '.'; # \-bbt=0 (default)
810 \& %bf = map { $_ => \-M $_ } grep {/\e.deb$/} dirents '.';   # \-bbt=1
811 \& %bf = map {$_ => \-M $_} grep {/\e.deb$/} dirents '.';     # \-bbt=2
812 .Ve
813 .IP "\fB\-sts\fR,   \fB\-\-space\-terminal\-semicolon\fR" 4
814 .IX Item "-sts,   --space-terminal-semicolon"
815 Some programmers prefer a space before all terminal semicolons.  The
816 default is for no such space, and is indicated with \fB\-nsts\fR or
817 \&\fB\-\-nospace\-terminal\-semicolon\fR.
818 .Sp
819 .Vb 2
820 \&        $i = 1 ;     #  \-sts
821 \&        $i = 1;      #  \-nsts   (default)
822 .Ve
823 .IP "\fB\-sfs\fR,   \fB\-\-space\-for\-semicolon\fR" 4
824 .IX Item "-sfs,   --space-for-semicolon"
825 Semicolons within \fBfor\fR loops may sometimes be hard to see,
826 particularly when commas are also present.  This option places spaces on
827 both sides of these special semicolons, and is the default.  Use
828 \&\fB\-nsfs\fR or \fB\-\-nospace\-for\-semicolon\fR to deactivate it.
829 .Sp
830 .Vb 2
831 \& for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) {  # \-sfs (default)
832 \& for ( @a = @$ap, $u = shift @a; @a; $u = $v ) {    # \-nsfs
833 .Ve
834 .IP "\fB\-asc\fR,  \fB\-\-add\-semicolons\fR" 4
835 .IX Item "-asc,  --add-semicolons"
836 Setting \fB\-asc\fR allows perltidy to add any missing optional semicolon at the end 
837 of a line which is followed by a closing curly brace on the next line.  This
838 is the default, and may be deactivated with \fB\-nasc\fR or \fB\-\-noadd\-semicolons\fR.
839 .IP "\fB\-dsm\fR,  \fB\-\-delete\-semicolons\fR" 4
840 .IX Item "-dsm,  --delete-semicolons"
841 Setting \fB\-dsm\fR allows perltidy to delete extra semicolons which are
842 simply empty statements.  This is the default, and may be deactivated
843 with \fB\-ndsm\fR or \fB\-\-nodelete\-semicolons\fR.  (Such semicolons are not
844 deleted, however, if they would promote a side comment to a block
845 comment).
846 .IP "\fB\-aws\fR,  \fB\-\-add\-whitespace\fR" 4
847 .IX Item "-aws,  --add-whitespace"
848 Setting this option allows perltidy to add certain whitespace improve
849 code readability.  This is the default. If you do not want any
850 whitespace added, but are willing to have some whitespace deleted, use
851 \&\fB\-naws\fR.  (Use \fB\-fws\fR to leave whitespace completely unchanged).
852 .IP "\fB\-dws\fR,  \fB\-\-delete\-old\-whitespace\fR" 4
853 .IX Item "-dws,  --delete-old-whitespace"
854 Setting this option allows perltidy to remove some old whitespace
855 between characters, if necessary.  This is the default.  If you
856 do not want any old whitespace removed, use \fB\-ndws\fR or
857 \&\fB\-\-nodelete\-old\-whitespace\fR.
858 .IP "Detailed whitespace controls around tokens" 4
859 .IX Item "Detailed whitespace controls around tokens"
860 For those who want more detailed control over the whitespace around
861 tokens, there are four parameters which can directly modify the default
862 whitespace rules built into perltidy for any token.  They are:
863 .Sp
864 \&\fB\-wls=s\fR or \fB\-\-want\-left\-space=s\fR,
865 .Sp
866 \&\fB\-nwls=s\fR or \fB\-\-nowant\-left\-space=s\fR,
867 .Sp
868 \&\fB\-wrs=s\fR or \fB\-\-want\-right\-space=s\fR,
869 .Sp
870 \&\fB\-nwrs=s\fR or \fB\-\-nowant\-right\-space=s\fR.
871 .Sp
872 These parameters are each followed by a quoted string, \fBs\fR, containing a
873 list of token types.  No more than one of each of these parameters
874 should be specified, because repeating a command-line parameter
875 always overwrites the previous one before perltidy ever sees it.
876 .Sp
877 To illustrate how these are used, suppose it is desired that there be no
878 space on either side of the token types \fB= + \- / *\fR.  The following two
879 parameters would specify this desire:
880 .Sp
881 .Vb 1
882 \&  \-nwls="= + \- / *"    \-nwrs="= + \- / *"
883 .Ve
884 .Sp
885 (Note that the token types are in quotes, and that they are separated by
886 spaces).  With these modified whitespace rules, the following line of math:
887 .Sp
888 .Vb 1
889 \&  $root = \-$b + sqrt( $b * $b \- 4. * $a * $c ) / ( 2. * $a );
890 .Ve
891 .Sp
892 becomes this:
893 .Sp
894 .Vb 1
895 \&  $root=\-$b+sqrt( $b*$b\-4.*$a*$c )/( 2.*$a );
896 .Ve
897 .Sp
898 These parameters should be considered to be hints to perltidy rather
899 than fixed rules, because perltidy must try to resolve conflicts that
900 arise between them and all of the other rules that it uses.  One
901 conflict that can arise is if, between two tokens, the left token wants
902 a space and the right one doesn't.  In this case, the token not wanting
903 a space takes priority.  
904 .Sp
905 It is necessary to have a list of all token types in order to create
906 this type of input.  Such a list can be obtained by the command
907 \&\fB\-\-dump\-token\-types\fR.  Also try the \-D flag on a short snippet of code
908 and look at the .DEBUG file to see the tokenization. 
909 .Sp
910 \&\fB\s-1WARNING\s0\fR Be sure to put these tokens in quotes to avoid having them
911 misinterpreted by your command shell.
912 .IP "Space between specific keywords and opening paren" 4
913 .IX Item "Space between specific keywords and opening paren"
914 When an opening paren follows a Perl keyword, no space is introduced after the
915 keyword, unless it is (by default) one of these:
916 .Sp
917 .Vb 2
918 \&   my local our and or eq ne if else elsif until unless 
919 \&   while for foreach return switch case given when
920 .Ve
921 .Sp
922 These defaults can be modified with two commands:
923 .Sp
924 \&\fB\-sak=s\fR  or \fB\-\-space\-after\-keyword=s\fR  adds keywords.
925 .Sp
926 \&\fB\-nsak=s\fR  or \fB\-\-nospace\-after\-keyword=s\fR  removes keywords.
927 .Sp
928 where \fBs\fR is a list of keywords (in quotes if necessary).  For example, 
929 .Sp
930 .Vb 2
931 \&  my ( $a, $b, $c ) = @_;    # default
932 \&  my( $a, $b, $c ) = @_;     # \-nsak="my local our"
933 .Ve
934 .Sp
935 To put a space after all keywords, see the next item.
936 .IP "Space between all keywords and opening parens" 4
937 .IX Item "Space between all keywords and opening parens"
938 When an opening paren follows a function or keyword, no space is introduced
939 after the keyword except for the keywords noted in the previous item.  To
940 always put a space between a function or keyword and its opening paren,
941 use the command:
942 .Sp
943 \&\fB\-skp\fR  or \fB\-\-space\-keyword\-paren\fR
944 .Sp
945 You will probably also want to use the flag \fB\-sfp\fR (next item) too.
946 .IP "Space between all function names and opening parens" 4
947 .IX Item "Space between all function names and opening parens"
948 When an opening paren follows a function the default is not to introduce
949 a space.  To cause a space to be introduced use:
950 .Sp
951 \&\fB\-sfp\fR  or \fB\-\-space\-function\-paren\fR
952 .Sp
953 .Vb 2
954 \&  myfunc( $a, $b, $c );    # default 
955 \&  myfunc ( $a, $b, $c );   # \-sfp
956 .Ve
957 .Sp
958 You will probably also want to use the flag \fB\-skp\fR (previous item) too.
959 .ie n .IP "Trimming whitespace around ""qw"" quotes" 4
960 .el .IP "Trimming whitespace around \f(CWqw\fR quotes" 4
961 .IX Item "Trimming whitespace around qw quotes"
962 \&\fB\-tqw\fR or \fB\-\-trim\-qw\fR provide the default behavior of trimming
963 spaces around multi-line \f(CW\*(C`qw\*(C'\fR quotes and indenting them appropriately.
964 .Sp
965 \&\fB\-ntqw\fR or \fB\-\-notrim\-qw\fR cause leading and trailing whitespace around
966 multi-line \f(CW\*(C`qw\*(C'\fR quotes to be left unchanged.  This option will not
967 normally be necessary, but was added for testing purposes, because in
968 some versions of perl, trimming \f(CW\*(C`qw\*(C'\fR quotes changes the syntax tree.
969 .Sh "Comment Controls"
970 .IX Subsection "Comment Controls"
971 Perltidy has a number of ways to control the appearance of both block comments
972 and side comments.  The term \fBblock comment\fR here refers to a full-line
973 comment, whereas \fBside comment\fR will refer to a comment which appears on a
974 line to the right of some code.
975 .IP "\fB\-ibc\fR,  \fB\-\-indent\-block\-comments\fR" 4
976 .IX Item "-ibc,  --indent-block-comments"
977 Block comments normally look best when they are indented to the same
978 level as the code which follows them.  This is the default behavior, but
979 you may use \fB\-nibc\fR to keep block comments left\-justified.  Here is an
980 example:
981 .Sp
982 .Vb 2
983 \&             # this comment is indented      (\-ibc, default)
984 \&             if ($task) { yyy(); }
985 .Ve
986 .Sp
987 The alternative is \fB\-nibc\fR:
988 .Sp
989 .Vb 2
990 \& # this comment is not indented              (\-nibc)
991 \&             if ($task) { yyy(); }
992 .Ve
993 .Sp
994 See also the next item, \fB\-isbc\fR, as well as \fB\-sbc\fR, for other ways to
995 have some indented and some outdented block comments.
996 .IP "\fB\-isbc\fR,  \fB\-\-indent\-spaced\-block\-comments\fR" 4
997 .IX Item "-isbc,  --indent-spaced-block-comments"
998 If there is no leading space on the line, then the comment will not be
999 indented, and otherwise it may be.
1000 .Sp
1001 If both \fB\-ibc\fR and \fB\-isbc\fR are set, then \fB\-isbc\fR takes priority.
1002 .IP "\fB\-olc\fR, \fB\-\-outdent\-long\-comments\fR" 4
1003 .IX Item "-olc, --outdent-long-comments"
1004 When \fB\-olc\fR is set, lines which are full-line (block) comments longer
1005 than the value \fBmaximum-line-length\fR will have their indentation
1006 removed.  This is the default; use \fB\-nolc\fR to prevent outdenting.
1007 .IP "\fB\-msc=n\fR,  \fB\-\-minimum\-space\-to\-comment=n\fR" 4
1008 .IX Item "-msc=n,  --minimum-space-to-comment=n"
1009 Side comments look best when lined up several spaces to the right of
1010 code.  Perltidy will try to keep comments at least n spaces to the
1011 right.  The default is n=4 spaces.
1012 .IP "\fB\-hsc\fR, \fB\-\-hanging\-side\-comments\fR" 4
1013 .IX Item "-hsc, --hanging-side-comments"
1014 By default, perltidy tries to identify and align \*(L"hanging side
1015 comments\*(R", which are something like this:
1016 .Sp
1017 .Vb 3
1018 \&        my $IGNORE = 0;    # This is a side comment
1019 \&                           # This is a hanging side comment
1020 \&                           # And so is this
1021 .Ve
1022 .Sp
1023 A comment is considered to be a hanging side comment if (1) it immediately
1024 follows a line with a side comment, or another hanging side comment, and
1025 (2) there is some leading whitespace on the line.
1026 To deactivate this feature, use \fB\-nhsc\fR or \fB\-\-nohanging\-side\-comments\fR.  
1027 If block comments are preceded by a blank line, or have no leading
1028 whitespace, they will not be mistaken as hanging side comments.
1029 .IP "Closing Side Comments" 4
1030 .IX Item "Closing Side Comments"
1031 A closing side comment is a special comment which perltidy can
1032 automatically create and place after the closing brace of a code block.
1033 They can be useful for code maintenance and debugging.  The command
1034 \&\fB\-csc\fR (or \fB\-\-closing\-side\-comments\fR) adds or updates closing side
1035 comments.  For example, here is a small code snippet
1036 .Sp
1037 .Vb 8
1038 \&        sub message {
1039 \&            if ( !defined( $_[0] ) ) {
1040 \&                print("Hello, World\en");
1041 \&            }
1042 \&            else {
1043 \&                print( $_[0], "\en" );
1044 \&            }
1045 \&        }
1046 .Ve
1047 .Sp
1048 And here is the result of processing with \f(CW\*(C`perltidy \-csc\*(C'\fR:
1049 .Sp
1050 .Vb 8
1051 \&        sub message {
1052 \&            if ( !defined( $_[0] ) ) {
1053 \&                print("Hello, World\en");
1054 \&            }
1055 \&            else {
1056 \&                print( $_[0], "\en" );
1057 \&            }
1058 \&        } ## end sub message
1059 .Ve
1060 .Sp
1061 A closing side comment was added for \f(CW\*(C`sub message\*(C'\fR in this case, but not
1062 for the \f(CW\*(C`if\*(C'\fR and \f(CW\*(C`else\*(C'\fR blocks, because they were below the 6 line
1063 cutoff limit for adding closing side comments.  This limit may be
1064 changed with the \fB\-csci\fR command, described below.
1065 .Sp
1066 The command \fB\-dcsc\fR (or \fB\-\-delete\-closing\-side\-comments\fR) reverses this 
1067 process and removes these comments.
1068 .Sp
1069 Several commands are available to modify the behavior of these two basic
1070 commands, \fB\-csc\fR and \fB\-dcsc\fR:
1071 .RS 4
1072 .IP "\fB\-csci=n\fR, or \fB\-\-closing\-side\-comment\-interval=n\fR" 4
1073 .IX Item "-csci=n, or --closing-side-comment-interval=n"
1074 where \f(CW\*(C`n\*(C'\fR is the minimum number of lines that a block must have in
1075 order for a closing side comment to be added.  The default value is
1076 \&\f(CW\*(C`n=6\*(C'\fR.  To illustrate:
1077 .Sp
1078 .Vb 9
1079 \&        # perltidy \-csci=2 \-csc
1080 \&        sub message {
1081 \&            if ( !defined( $_[0] ) ) {
1082 \&                print("Hello, World\en");
1083 \&            } ## end if ( !defined( $_[0] ))
1084 \&            else {
1085 \&                print( $_[0], "\en" );
1086 \&            } ## end else [ if ( !defined( $_[0] ))
1087 \&        } ## end sub message
1088 .Ve
1089 .Sp
1090 Now the \f(CW\*(C`if\*(C'\fR and \f(CW\*(C`else\*(C'\fR blocks are commented.  However, now this has
1091 become very cluttered.
1092 .IP "\fB\-cscp=string\fR, or \fB\-\-closing\-side\-comment\-prefix=string\fR" 4
1093 .IX Item "-cscp=string, or --closing-side-comment-prefix=string"
1094 where string is the prefix used before the name of the block type.  The
1095 default prefix, shown above, is \f(CW\*(C`## end\*(C'\fR.  This string will be added to
1096 closing side comments, and it will also be used to recognize them in
1097 order to update, delete, and format them.  Any comment identified as a
1098 closing side comment will be placed just a single space to the right of
1099 its closing brace.
1100 .IP "\fB\-cscl=string\fR, or \fB\-\-closing\-side\-comment\-list\-string\fR" 4
1101 .IX Item "-cscl=string, or --closing-side-comment-list-string"
1102 where \f(CW\*(C`string\*(C'\fR is a list of block types to be tagged with closing side
1103 comments.  By default, all code block types preceded by a keyword or
1104 label (such as \f(CW\*(C`if\*(C'\fR, \f(CW\*(C`sub\*(C'\fR, and so on) will be tagged.  The \fB\-cscl\fR
1105 command changes the default list to be any selected block types; see
1106 \&\*(L"Specifying Block Types\*(R".
1107 For example, the following command
1108 requests that only \f(CW\*(C`sub\*(C'\fR's, labels, \f(CW\*(C`BEGIN\*(C'\fR, and \f(CW\*(C`END\*(C'\fR blocks be
1109 affected by any \fB\-csc\fR or \fB\-dcsc\fR operation:
1110 .Sp
1111 .Vb 1
1112 \&   \-cscl="sub : BEGIN END"
1113 .Ve
1114 .IP "\fB\-csct=n\fR, or \fB\-\-closing\-side\-comment\-maximum\-text=n\fR" 4
1115 .IX Item "-csct=n, or --closing-side-comment-maximum-text=n"
1116 The text appended to certain block types, such as an \f(CW\*(C`if\*(C'\fR block, is
1117 whatever lies between the keyword introducing the block, such as \f(CW\*(C`if\*(C'\fR,
1118 and the opening brace.  Since this might be too much text for a side
1119 comment, there needs to be a limit, and that is the purpose of this
1120 parameter.  The default value is \f(CW\*(C`n=20\*(C'\fR, meaning that no additional
1121 tokens will be appended to this text after its length reaches 20
1122 characters.  Omitted text is indicated with \f(CW\*(C`...\*(C'\fR.  (Tokens, including
1123 sub names, are never truncated, however, so actual lengths may exceed
1124 this).  To illustrate, in the above example, the appended text of the
1125 first block is \f(CW\*(C` ( !defined( $_[0] )...\*(C'\fR.  The existing limit of
1126 \&\f(CW\*(C`n=20\*(C'\fR caused this text to be truncated, as indicated by the \f(CW\*(C`...\*(C'\fR.
1127 .IP "\fB\-csce=n\fR, or \fB\-\-closing\-side\-comment\-else\-flag=n\fR" 4
1128 .IX Item "-csce=n, or --closing-side-comment-else-flag=n"
1129 The default, \fBn=0\fR, places the text of the opening \f(CW\*(C`if\*(C'\fR statement after any
1130 terminal \f(CW\*(C`else\*(C'\fR.
1131 .Sp
1132 If \fBn=2\fR is used, then each \f(CW\*(C`elsif\*(C'\fR is also given the text of the opening
1133 \&\f(CW\*(C`if\*(C'\fR statement.  Also, an \f(CW\*(C`else\*(C'\fR will include the text of a preceding
1134 \&\f(CW\*(C`elsif\*(C'\fR statement.  Note that this may result some long closing
1135 side comments.
1136 .Sp
1137 If \fBn=1\fR is used, the results will be the same as \fBn=2\fR whenever the
1138 resulting line length is less than the maximum allowed.
1139 .IP "\fB\-cscw\fR, or \fB\-\-closing\-side\-comment\-warnings\fR" 4
1140 .IX Item "-cscw, or --closing-side-comment-warnings"
1141 This parameter is intended to help make the initial transition to the use of
1142 closing side comments.  
1143 It causes two
1144 things to happen if a closing side comment replaces an existing, different
1145 closing side comment:  first, an error message will be issued, and second, the
1146 original side comment will be placed alone on a new specially marked comment
1147 line for later attention. 
1148 .Sp
1149 The intent is to avoid clobbering existing hand-written side comments
1150 which happen to match the pattern of closing side comments. This flag
1151 should only be needed on the first run with \fB\-csc\fR.
1152 .RE
1153 .RS 4
1154 .Sp
1155 \&\fBImportant Notes on Closing Side Comments:\fR 
1156 .IP "*" 4
1157 Closing side comments are only placed on lines terminated with a closing
1158 brace.  Certain closing styles, such as the use of cuddled elses
1159 (\fB\-ce\fR), preclude the generation of some closing side comments.
1160 .IP "*" 4
1161 Please note that adding or deleting of closing side comments takes
1162 place only through the commands \fB\-csc\fR or \fB\-dcsc\fR.  The other commands,
1163 if used, merely modify the behavior of these two commands.  
1164 .IP "*" 4
1165 It is recommended that the \fB\-cscw\fR flag be used along with \fB\-csc\fR on
1166 the first use of perltidy on a given file.  This will prevent loss of
1167 any existing side comment data which happens to have the csc prefix.
1168 .IP "*" 4
1169 Once you use \fB\-csc\fR, you should continue to use it so that any
1170 closing side comments remain correct as code changes.  Otherwise, these
1171 comments will become incorrect as the code is updated.
1172 .IP "*" 4
1173 If you edit the closing side comments generated by perltidy, you must also
1174 change the prefix to be different from the closing side comment prefix.
1175 Otherwise, your edits will be lost when you rerun perltidy with \fB\-csc\fR.   For
1176 example, you could simply change \f(CW\*(C`## end\*(C'\fR to be \f(CW\*(C`## End\*(C'\fR, since the test is
1177 case sensitive.  You may also want to use the \fB\-ssc\fR flag to keep these
1178 modified closing side comments spaced the same as actual closing side comments.
1179 .IP "*" 4
1180 Temporarily generating closing side comments is a useful technique for
1181 exploring and/or debugging a perl script, especially one written by someone
1182 else.  You can always remove them with \fB\-dcsc\fR.
1183 .RE
1184 .RS 4
1185 .RE
1186 .IP "Static Block Comments" 4
1187 .IX Item "Static Block Comments"
1188 Static block comments are block comments with a special leading pattern,
1189 \&\f(CW\*(C`##\*(C'\fR by default, which will be treated slightly differently from other
1190 block comments.  They effectively behave as if they had glue along their
1191 left and top edges, because they stick to the left edge and previous line
1192 when there is no blank spaces in those places.  This option is
1193 particularly useful for controlling how commented code is displayed.
1194 .RS 4
1195 .IP "\fB\-sbc\fR, \fB\-\-static\-block\-comments\fR" 4
1196 .IX Item "-sbc, --static-block-comments"
1197 When \fB\-sbc\fR is used, a block comment with a special leading pattern, \f(CW\*(C`##\*(C'\fR by
1198 default, will be treated specially. 
1199 .Sp
1200 Comments so identified  are treated as follows: 
1201 .RS 4
1202 .IP "*" 4
1203 If there is no leading space on the line, then the comment will not
1204 be indented, and otherwise it may be,
1205 .IP "*" 4
1206 no new blank line will be
1207 inserted before such a comment, and 
1208 .IP "*" 4
1209 such a comment will never become
1210 a hanging side comment.  
1211 .RE
1212 .RS 4
1213 .Sp
1214 For example, assuming \f(CW@month_of_year\fR is
1215 left\-adjusted:
1216 .Sp
1217 .Vb 4
1218 \&    @month_of_year = (    # \-sbc (default)
1219 \&        'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1220 \&    ##  'Dec', 'Nov'
1221 \&        'Nov', 'Dec');
1222 .Ve
1223 .Sp
1224 Without this convention, the above code would become
1225 .Sp
1226 .Vb 2
1227 \&    @month_of_year = (   # \-nsbc
1228 \&        'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1229 .Ve
1230 .Sp
1231 .Vb 3
1232 \&        ##  'Dec', 'Nov'
1233 \&        'Nov', 'Dec'
1234 \&    );
1235 .Ve
1236 .Sp
1237 which is not as clear.
1238 The default is to use \fB\-sbc\fR.  This may be deactivated with \fB\-nsbc\fR.
1239 .RE
1240 .IP "\fB\-sbcp=string\fR, \fB\-\-static\-block\-comment\-prefix=string\fR" 4
1241 .IX Item "-sbcp=string, --static-block-comment-prefix=string"
1242 This parameter defines the prefix used to identify static block comments
1243 when the \fB\-sbc\fR parameter is set.  The default prefix is \f(CW\*(C`##\*(C'\fR,
1244 corresponding to \f(CW\*(C`\-sbcp=##\*(C'\fR.  The prefix is actually part of a perl 
1245 pattern used to match lines and it must either begin with \f(CW\*(C`#\*(C'\fR or \f(CW\*(C`^#\*(C'\fR.  
1246 In the first case a prefix ^\es* will be added to match any leading
1247 whitespace, while in the second case the pattern will match only
1248 comments with no leading whitespace.  For example, to
1249 identify all comments as static block comments, one would use \f(CW\*(C`\-sbcp=#\*(C'\fR.
1250 To identify all left-adjusted comments as static block comments, use \f(CW\*(C`\-sbcp='^#'\*(C'\fR.
1251 .Sp
1252 Please note that \fB\-sbcp\fR merely defines the pattern used to identify static
1253 block comments; it will not be used unless the switch \fB\-sbc\fR is set.  Also,
1254 please be aware that since this string is used in a perl regular expression
1255 which identifies these comments, it must enable a valid regular expression to
1256 be formed.
1257 .IP "\fB\-osbc\fR, \fB\-\-outdent\-static\-block\-comments\fR" 4
1258 .IX Item "-osbc, --outdent-static-block-comments"
1259 The command \fB\-osbc\fR will will cause static block comments to be outdented by 2
1260 spaces (or whatever \fB\-ci=n\fR has been set to), if possible.
1261 .RE
1262 .RS 4
1263 .RE
1264 .IP "Static Side Comments" 4
1265 .IX Item "Static Side Comments"
1266 Static side comments are side comments with a special leading pattern.
1267 This option can be useful for controlling how commented code is displayed
1268 when it is a side comment.
1269 .RS 4
1270 .IP "\fB\-ssc\fR, \fB\-\-static\-side\-comments\fR" 4
1271 .IX Item "-ssc, --static-side-comments"
1272 When \fB\-ssc\fR is used, a side comment with a static leading pattern, which is
1273 \&\f(CW\*(C`##\*(C'\fR by default, will be be spaced only a single space from previous
1274 character, and it will not be vertically aligned with other side comments.
1275 .Sp
1276 The default is \fB\-nssc\fR.
1277 .IP "\fB\-sscp=string\fR, \fB\-\-static\-side\-comment\-prefix=string\fR" 4
1278 .IX Item "-sscp=string, --static-side-comment-prefix=string"
1279 This parameter defines the prefix used to identify static side comments
1280 when the \fB\-ssc\fR parameter is set.  The default prefix is \f(CW\*(C`##\*(C'\fR,
1281 corresponding to \f(CW\*(C`\-sscp=##\*(C'\fR.  
1282 .Sp
1283 Please note that \fB\-sscp\fR merely defines the pattern used to identify
1284 static side comments; it will not be used unless the switch \fB\-ssc\fR is
1285 set.  Also, note that this string is used in a perl regular expression
1286 which identifies these comments, so it must enable a valid regular
1287 expression to be formed.
1288 .RE
1289 .RS 4
1290 .RE
1291 .Sh "Skipping Selected Sections of Code"
1292 .IX Subsection "Skipping Selected Sections of Code"
1293 Selected lines of code may be passed verbatim to the output without any
1294 formatting.  This feature is enabled by default but can be disabled with
1295 the \fB\-\-noformat\-skipping\fR or \fB\-nfs\fR flag.  It should be used sparingly to
1296 avoid littering code with markers, but it might be helpful for working
1297 around occasional problems.  For example it might be useful for keeping
1298 the indentation of old commented code unchanged, keeping indentation of
1299 long blocks of aligned comments unchanged, keeping certain list
1300 formatting unchanged, or working around a glitch in perltidy.
1301 .IP "\fB\-fs\fR,  \fB\-\-format\-skipping\fR" 4
1302 .IX Item "-fs,  --format-skipping"
1303 This flag, which is enabled by default, causes any code between
1304 special beginning and ending comment markers to be passed to the
1305 output without formatting.  The default beginning marker is #<<<
1306 and the default ending marker is #>>> but they
1307 may be changed (see next items below).  Additional text may appear on
1308 these special comment lines provided that it is separated from the
1309 marker by at least one space.  For example
1310 .Sp
1311 .Vb 7
1312 \& #<<<  do not let perltidy touch this
1313 \&    my @list = (1,
1314 \&                1, 1,
1315 \&                1, 2, 1,
1316 \&                1, 3, 3, 1,
1317 \&                1, 4, 6, 4, 1,);
1318 \& #>>>
1319 .Ve
1320 .Sp
1321 The comment markers may be placed at any location that a block comment may
1322 appear.  If they do not appear to be working, use the \-log flag and examine the
1323 \&\fI.LOG\fR file.  Use \fB\-nfs\fR to disable this feature.
1324 .IP "\fB\-fsb=string\fR,  \fB\-\-format\-skipping\-begin=string\fR" 4
1325 .IX Item "-fsb=string,  --format-skipping-begin=string"
1326 The \fB\-fsb=string\fR parameter may be used to change the beginning marker for
1327 format skipping.  The default is equivalent to \-fsb='#<<<'.  The string that
1328 you enter must begin with a # and should be in quotes as necessary to get past
1329 the command shell of your system.  It is actually the leading text of a pattern
1330 that is constructed by appending a '\es', so you must also include backslashes
1331 for characters to be taken literally rather than as patterns.  
1332 .Sp
1333 Some examples show how example strings become patterns:
1334 .Sp
1335 .Vb 3
1336 \& \-fsb='#\e{\e{\e{' becomes /^#\e{\e{\e{\es/  which matches  #{{{ but not #{{{{
1337 \& \-fsb='#\e*\e*'   becomes /^#\e*\e*\es/    which matches  #** but not #***
1338 \& \-fsb='#\e*{2,}' becomes /^#\e*{2,}\es/  which matches  #** and #*****
1339 .Ve
1340 .IP "\fB\-fse=string\fR,  \fB\-\-format\-skipping\-end=string\fR" 4
1341 .IX Item "-fse=string,  --format-skipping-end=string"
1342 The \fB\-fsb=string\fR is the corresponding parameter used to change the
1343 ending marker for format skipping.  The default is equivalent to
1344 \&\-fse='#<<<'.  
1345 .Sh "Line Break Control"
1346 .IX Subsection "Line Break Control"
1347 .IP "\fB\-fnl\fR,  \fB\-\-freeze\-newlines\fR" 4
1348 .IX Item "-fnl,  --freeze-newlines"
1349 If you do not want any changes to the line breaks in your script, set
1350 \&\fB\-fnl\fR, and they will remain fixed, and the rest of the commands in
1351 this section and sections 
1352 \&\*(L"Controlling List Formatting\*(R",
1353 \&\*(L"Retaining or Ignoring Existing Line Breaks\*(R", and
1354 \&\*(L"Blank Line Control\*(R" will be ignored.  You may want to use \fB\-noll\fR
1355 with this.
1356 .IP "\fB\-ce\fR,   \fB\-\-cuddled\-else\fR" 4
1357 .IX Item "-ce,   --cuddled-else"
1358 Enable the \*(L"cuddled else\*(R" style, in which \f(CW\*(C`else\*(C'\fR and \f(CW\*(C`elsif\*(C'\fR are
1359 follow immediately after the curly brace closing the previous block.
1360 The default is not to use cuddled elses, and is indicated with the flag
1361 \&\fB\-nce\fR or \fB\-\-nocuddled\-else\fR.  Here is a comparison of the
1362 alternatives:
1363 .Sp
1364 .Vb 5
1365 \&  if ($task) {
1366 \&      yyy();
1367 \&  } else {    # \-ce
1368 \&      zzz();
1369 \&  }
1370 .Ve
1371 .Sp
1372 .Vb 6
1373 \&  if ($task) {
1374 \&        yyy();
1375 \&  }
1376 \&  else {    # \-nce  (default)
1377 \&        zzz();
1378 \&  }
1379 .Ve
1380 .IP "\fB\-bl\fR,    \fB\-\-opening\-brace\-on\-new\-line\fR" 4
1381 .IX Item "-bl,    --opening-brace-on-new-line"
1382 Use the flag \fB\-bl\fR to place the opening brace on a new line:
1383 .Sp
1384 .Vb 4
1385 \&  if ( $input_file eq '\-' )    # \-bl 
1386 \&  {                          
1387 \&      important_function();
1388 \&  }
1389 .Ve
1390 .Sp
1391 This flag applies to all structural blocks, including sub's (unless
1392 the \fB\-sbl\fR flag is set \*(-- see next item).
1393 .Sp
1394 The default style, \fB\-nbl\fR, places an opening brace on the same line as
1395 the keyword introducing it.  For example,
1396 .Sp
1397 .Vb 1
1398 \&  if ( $input_file eq '\-' ) {   # \-nbl (default)
1399 .Ve
1400 .IP "\fB\-sbl\fR,    \fB\-\-opening\-sub\-brace\-on\-new\-line\fR" 4
1401 .IX Item "-sbl,    --opening-sub-brace-on-new-line"
1402 The flag \fB\-sbl\fR can be used to override the value of \fB\-bl\fR for
1403 opening sub braces.  For example, 
1404 .Sp
1405 .Vb 1
1406 \& perltidy \-sbl
1407 .Ve
1408 .Sp
1409 produces this result:
1410 .Sp
1411 .Vb 9
1412 \& sub message
1413 \& {
1414 \&    if (!defined($_[0])) {
1415 \&        print("Hello, World\en");
1416 \&    }
1417 \&    else {
1418 \&        print($_[0], "\en");
1419 \&    }
1420 \& }
1421 .Ve
1422 .Sp
1423 This flag is negated with \fB\-nsbl\fR.  If \fB\-sbl\fR is not specified,
1424 the value of \fB\-bl\fR is used.
1425 .IP "\fB\-bli\fR,    \fB\-\-brace\-left\-and\-indent\fR" 4
1426 .IX Item "-bli,    --brace-left-and-indent"
1427 The flag \fB\-bli\fR is the same as \fB\-bl\fR but in addition it causes one 
1428 unit of continuation indentation ( see \fB\-ci\fR ) to be placed before 
1429 an opening and closing block braces.
1430 .Sp
1431 For example,
1432 .Sp
1433 .Vb 4
1434 \&        if ( $input_file eq '\-' )    # \-bli
1435 \&          {
1436 \&            important_function();
1437 \&          }
1438 .Ve
1439 .Sp
1440 By default, this extra indentation occurs for blocks of type:
1441 \&\fBif\fR, \fBelsif\fR, \fBelse\fR, \fBunless\fR, \fBfor\fR, \fBforeach\fR, \fBsub\fR, 
1442 \&\fBwhile\fR, \fBuntil\fR, and also with a preceding label.  The next item
1443 shows how to change this.
1444 .IP "\fB\-blil=s\fR,    \fB\-\-brace\-left\-and\-indent\-list=s\fR" 4
1445 .IX Item "-blil=s,    --brace-left-and-indent-list=s"
1446 Use this parameter to change the types of block braces for which the
1447 \&\fB\-bli\fR flag applies; see \*(L"Specifying Block Types\*(R".  For example,
1448 \&\fB\-blil='if elsif else'\fR would apply it to only \f(CW\*(C`if/elsif/else\*(C'\fR blocks.
1449 .IP "\fB\-bar\fR,    \fB\-\-opening\-brace\-always\-on\-right\fR" 4
1450 .IX Item "-bar,    --opening-brace-always-on-right"
1451 The default style, \fB\-nbl\fR places the opening code block brace on a new
1452 line if it does not fit on the same line as the opening keyword, like
1453 this:
1454 .Sp
1455 .Vb 5
1456 \&        if ( $bigwasteofspace1 && $bigwasteofspace2
1457 \&          || $bigwasteofspace3 && $bigwasteofspace4 )
1458 \&        {
1459 \&            big_waste_of_time();
1460 \&        }
1461 .Ve
1462 .Sp
1463 To force the opening brace to always be on the right, use the \fB\-bar\fR
1464 flag.  In this case, the above example becomes
1465 .Sp
1466 .Vb 4
1467 \&        if ( $bigwasteofspace1 && $bigwasteofspace2
1468 \&          || $bigwasteofspace3 && $bigwasteofspace4 ) {
1469 \&            big_waste_of_time();
1470 \&        }
1471 .Ve
1472 .Sp
1473 A conflict occurs if both \fB\-bl\fR and \fB\-bar\fR are specified.
1474 .IP "\fB\-otr\fR,  \fB\-\-opening\-token\-right\fR and related flags" 4
1475 .IX Item "-otr,  --opening-token-right and related flags"
1476 The \fB\-otr\fR flag is a hint that perltidy should not place a break between a
1477 comma and an opening token.  For example:
1478 .Sp
1479 .Vb 6
1480 \&    # default formatting
1481 \&    push @{ $self\->{$module}{$key} },
1482 \&      {
1483 \&        accno       => $ref\->{accno},
1484 \&        description => $ref\->{description}
1485 \&      };
1486 .Ve
1487 .Sp
1488 .Vb 5
1489 \&    # perltidy \-otr
1490 \&    push @{ $self\->{$module}{$key} }, {
1491 \&        accno       => $ref\->{accno},
1492 \&        description => $ref\->{description}
1493 \&      };
1494 .Ve
1495 .Sp
1496 The flag \fB\-otr\fR is actually a synonym for three other flags
1497 which can be used to control parens, hash braces, and square brackets
1498 separately if desired:
1499 .Sp
1500 .Vb 3
1501 \&  \-opr  or \-\-opening\-paren\-right
1502 \&  \-ohbr or \-\-opening\-hash\-brace\-right
1503 \&  \-osbr or \-\-opening\-square\-bracket\-right
1504 .Ve
1505 .IP "Vertical tightness of non-block curly braces, parentheses, and square brackets." 4
1506 .IX Item "Vertical tightness of non-block curly braces, parentheses, and square brackets."
1507 These parameters control what shall be called vertical tightness.  Here are the
1508 main points:
1509 .RS 4
1510 .IP "*" 4
1511 Opening tokens (except for block braces) are controlled by \fB\-vt=n\fR, or
1512 \&\fB\-\-vertical\-tightness=n\fR, where
1513 .Sp
1514 .Vb 4
1515 \& \-vt=0 always break a line after opening token (default). 
1516 \& \-vt=1 do not break unless this would produce more than one 
1517 \&         step in indentation in a line.
1518 \& \-vt=2 never break a line after opening token
1519 .Ve
1520 .IP "*" 4
1521 You must also use the \fB\-lp\fR flag when you use the \fB\-vt\fR flag; the
1522 reason is explained below.
1523 .IP "*" 4
1524 Closing tokens (except for block braces) are controlled by \fB\-vtc=n\fR, or
1525 \&\fB\-\-vertical\-tightness\-closing=n\fR, where
1526 .Sp
1527 .Vb 5
1528 \& \-vtc=0 always break a line before a closing token (default), 
1529 \& \-vtc=1 do not break before a closing token which is followed 
1530 \&        by a semicolon or another closing token, and is not in 
1531 \&        a list environment.
1532 \& \-vtc=2 never break before a closing token.
1533 .Ve
1534 .Sp
1535 The rules for \fB\-vtc=1\fR are designed to maintain a reasonable balance
1536 between tightness and readability in complex lists.
1537 .IP "*" 4
1538 Different controls may be applied to to different token types,
1539 and it is also possible to control block braces; see below.
1540 .IP "*" 4
1541 Finally, please note that these vertical tightness flags are merely
1542 hints to the formatter, and it cannot always follow them.  Things which
1543 make it difficult or impossible include comments, blank lines, blocks of
1544 code within a list, and possibly the lack of the \fB\-lp\fR parameter.
1545 Also, these flags may be ignored for very small lists (2 or 3 lines in
1546 length).
1547 .RE
1548 .RS 4
1549 .Sp
1550 Here are some examples: 
1551 .Sp
1552 .Vb 7
1553 \&    # perltidy \-lp \-vt=0 \-vtc=0
1554 \&    %romanNumerals = (
1555 \&                       one   => 'I',
1556 \&                       two   => 'II',
1557 \&                       three => 'III',
1558 \&                       four  => 'IV',
1559 \&    );
1560 .Ve
1561 .Sp
1562 .Vb 6
1563 \&    # perltidy \-lp \-vt=1 \-vtc=0
1564 \&    %romanNumerals = ( one   => 'I',
1565 \&                       two   => 'II',
1566 \&                       three => 'III',
1567 \&                       four  => 'IV',
1568 \&    );
1569 .Ve
1570 .Sp
1571 .Vb 5
1572 \&    # perltidy \-lp \-vt=1 \-vtc=1
1573 \&    %romanNumerals = ( one   => 'I',
1574 \&                       two   => 'II',
1575 \&                       three => 'III',
1576 \&                       four  => 'IV', );
1577 .Ve
1578 .Sp
1579 The difference between \fB\-vt=1\fR and \fB\-vt=2\fR is shown here:
1580 .Sp
1581 .Vb 6
1582 \&    # perltidy \-lp \-vt=1 
1583 \&    $init\->add(
1584 \&                mysprintf( "(void)find_threadsv(%s);",
1585 \&                           cstring( $threadsv_names[ $op\->targ ] )
1586 \&                )
1587 \&    );
1588 .Ve
1589 .Sp
1590 .Vb 5
1591 \&    # perltidy \-lp \-vt=2 
1592 \&    $init\->add( mysprintf( "(void)find_threadsv(%s);",
1593 \&                           cstring( $threadsv_names[ $op\->targ ] )
1594 \&                )
1595 \&    );
1596 .Ve
1597 .Sp
1598 With \fB\-vt=1\fR, the line ending in \f(CW\*(C`add(\*(C'\fR does not combine with the next
1599 line because the next line is not balanced.  This can help with
1600 readability, but \fB\-vt=2\fR can be used to ignore this rule.
1601 .Sp
1602 The tightest, and least readable, code is produced with both \f(CW\*(C`\-vt=2\*(C'\fR and
1603 \&\f(CW\*(C`\-vtc=2\*(C'\fR:
1604 .Sp
1605 .Vb 3
1606 \&    # perltidy \-lp \-vt=2 \-vtc=2
1607 \&    $init\->add( mysprintf( "(void)find_threadsv(%s);",
1608 \&                           cstring( $threadsv_names[ $op\->targ ] ) ) );
1609 .Ve
1610 .Sp
1611 Notice how the code in all of these examples collapses vertically as
1612 \&\fB\-vt\fR increases, but the indentation remains unchanged.  This is
1613 because perltidy implements the \fB\-vt\fR parameter by first formatting as
1614 if \fB\-vt=0\fR, and then simply overwriting one output line on top of the
1615 next, if possible, to achieve the desired vertical tightness.  The
1616 \&\fB\-lp\fR indentation style has been designed to allow this vertical
1617 collapse to occur, which is why it is required for the \fB\-vt\fR parameter.
1618 .Sp
1619 The \fB\-vt=n\fR and \fB\-vtc=n\fR parameters apply to each type of container
1620 token.  If desired, vertical tightness controls can be applied
1621 independently to each of the closing container token types.
1622 .Sp
1623 The parameters for controlling parentheses are \fB\-pvt=n\fR or
1624 \&\fB\-\-paren\-vertical\-tightness=n\fR, and \fB\-pcvt=n\fR or
1625 \&\fB\-\-paren\-vertical\-tightness\-closing=n\fR.
1626 .Sp
1627 Likewise, the parameters for square brackets are \fB\-sbvt=n\fR or
1628 \&\fB\-\-square\-bracket\-vertical\-tightness=n\fR, and \fB\-sbcvt=n\fR or
1629 \&\fB\-\-square\-bracket\-vertical\-tightness\-closing=n\fR.
1630 .Sp
1631 Finally, the parameters for controlling non-code block braces are
1632 \&\fB\-bvt=n\fR or \fB\-\-brace\-vertical\-tightness=n\fR, and \fB\-bcvt=n\fR or
1633 \&\fB\-\-brace\-vertical\-tightness\-closing=n\fR.
1634 .Sp
1635 In fact, the parameter \fB\-vt=n\fR is actually just an abbreviation for
1636 \&\fB\-pvt=n \-bvt=n sbvt=n\fR, and likewise \fB\-vtc=n\fR is an abbreviation
1637 for \fB\-pvtc=n \-bvtc=n sbvtc=n\fR.
1638 .RE
1639 .IP "\fB\-bbvt=n\fR or \fB\-\-block\-brace\-vertical\-tightness=n\fR" 4
1640 .IX Item "-bbvt=n or --block-brace-vertical-tightness=n"
1641 The \fB\-bbvt=n\fR flag is just like the \fB\-vt=n\fR flag but applies
1642 to opening code block braces.
1643 .Sp
1644 .Vb 4
1645 \& \-bbvt=0 break after opening block brace (default). 
1646 \& \-bbvt=1 do not break unless this would produce more than one 
1647 \&         step in indentation in a line.
1648 \& \-bbvt=2 do not break after opening block brace.
1649 .Ve
1650 .Sp
1651 It is necessary to also use either \fB\-bl\fR or \fB\-bli\fR for this to work,
1652 because, as with other vertical tightness controls, it is implemented by
1653 simply overwriting a line ending with an opening block brace with the
1654 subsequent line.  For example:
1655 .Sp
1656 .Vb 10
1657 \&    # perltidy \-bli \-bbvt=0
1658 \&    if ( open( FILE, "< $File" ) )
1659 \&      {
1660 \&        while ( $File = <FILE> )
1661 \&          {
1662 \&            $In .= $File;
1663 \&            $count++;
1664 \&          }
1665 \&        close(FILE);
1666 \&      }
1667 .Ve
1668 .Sp
1669 .Vb 8
1670 \&    # perltidy \-bli \-bbvt=1
1671 \&    if ( open( FILE, "< $File" ) )
1672 \&      { while ( $File = <FILE> )
1673 \&          { $In .= $File;
1674 \&            $count++;
1675 \&          }
1676 \&        close(FILE);
1677 \&      }
1678 .Ve
1679 .Sp
1680 By default this applies to blocks associated with keywords \fBif\fR,
1681 \&\fBelsif\fR, \fBelse\fR, \fBunless\fR, \fBfor\fR, \fBforeach\fR, \fBsub\fR, \fBwhile\fR,
1682 \&\fBuntil\fR, and also with a preceding label.  This can be changed with
1683 the parameter \fB\-bbvtl=string\fR, or
1684 \&\fB\-\-block\-brace\-vertical\-tightness\-list=string\fR, where \fBstring\fR is a
1685 space-separated list of block types.  For more information on the
1686 possible values of this string, see \*(L"Specifying Block Types\*(R"
1687 .Sp
1688 For example, if we want to just apply this style to \f(CW\*(C`if\*(C'\fR,
1689 \&\f(CW\*(C`elsif\*(C'\fR, and \f(CW\*(C`else\*(C'\fR blocks, we could use 
1690 \&\f(CW\*(C`perltidy \-bli \-bbvt=1 \-bbvtl='if elsif else'\*(C'\fR.
1691 .Sp
1692 There is no vertical tightness control for closing block braces; with
1693 the exception of one-line blocks, they will normally remain on a 
1694 separate line.
1695 .IP "\fB\-sot\fR,  \fB\-\-stack\-opening\-token\fR and related flags" 4
1696 .IX Item "-sot,  --stack-opening-token and related flags"
1697 The \fB\-sot\fR flag tells perltidy to \*(L"stack\*(R" opening tokens
1698 when possible to avoid lines with isolated opening tokens.
1699 .Sp
1700 For example:
1701 .Sp
1702 .Vb 8
1703 \&    # default
1704 \&    $opt_c = Text::CSV_XS\->new(
1705 \&        {
1706 \&            binary       => 1,
1707 \&            sep_char     => $opt_c,
1708 \&            always_quote => 1,
1709 \&        }
1710 \&    );
1711 .Ve
1712 .Sp
1713 .Vb 7
1714 \&    # \-sot
1715 \&    $opt_c = Text::CSV_XS\->new( {
1716 \&            binary       => 1,
1717 \&            sep_char     => $opt_c,
1718 \&            always_quote => 1,
1719 \&        }
1720 \&    );
1721 .Ve
1722 .Sp
1723 For detailed control of individual closing tokens the following
1724 controls can be used:
1725 .Sp
1726 .Vb 3
1727 \&  \-sop  or \-\-stack\-opening\-paren
1728 \&  \-sohb or \-\-stack\-opening\-hash\-brace
1729 \&  \-sosb or \-\-stack\-opening\-square\-bracket
1730 .Ve
1731 .Sp
1732 The flag \fB\-sot\fR is a synonym for \fB\-sop \-sohb \-sosb\fR.
1733 .IP "\fB\-sct\fR,  \fB\-\-stack\-closing\-token\fR and related flags" 4
1734 .IX Item "-sct,  --stack-closing-token and related flags"
1735 The \fB\-sct\fR flag tells perltidy to \*(L"stack\*(R" closing tokens
1736 when possible to avoid lines with isolated closing tokens.
1737 .Sp
1738 For example:
1739 .Sp
1740 .Vb 8
1741 \&    # default
1742 \&    $opt_c = Text::CSV_XS\->new(
1743 \&        {
1744 \&            binary       => 1,
1745 \&            sep_char     => $opt_c,
1746 \&            always_quote => 1,
1747 \&        }
1748 \&    );
1749 .Ve
1750 .Sp
1751 .Vb 7
1752 \&    # \-sct
1753 \&    $opt_c = Text::CSV_XS\->new(
1754 \&        {
1755 \&            binary       => 1,
1756 \&            sep_char     => $opt_c,
1757 \&            always_quote => 1,
1758 \&        } );
1759 .Ve
1760 .Sp
1761 The \fB\-sct\fR flag is somewhat similar to the \fB\-vtc\fR flags, and in some
1762 cases it can give a similar result.  The difference is that the \fB\-vtc\fR
1763 flags try to avoid lines with leading opening tokens by \*(L"hiding\*(R" them at
1764 the end of a previous line, whereas the \fB\-sct\fR flag merely tries to
1765 reduce the number of lines with isolated closing tokens by stacking them
1766 but does not try to hide them.  For example:
1767 .Sp
1768 .Vb 6
1769 \&    # \-vtc=2
1770 \&    $opt_c = Text::CSV_XS\->new(
1771 \&        {
1772 \&            binary       => 1,
1773 \&            sep_char     => $opt_c,
1774 \&            always_quote => 1, } );
1775 .Ve
1776 .Sp
1777 For detailed control of the stacking of individual closing tokens the
1778 following controls can be used:
1779 .Sp
1780 .Vb 3
1781 \&  \-scp  or \-\-stack\-closing\-paren
1782 \&  \-schb or \-\-stack\-closing\-hash\-brace
1783 \&  \-scsb or \-\-stack\-closing\-square\-bracket
1784 .Ve
1785 .Sp
1786 The flag \fB\-sct\fR is a synonym for \fB\-scp \-schb \-scsb\fR.
1787 .IP "\fB\-dnl\fR,  \fB\-\-delete\-old\-newlines\fR" 4
1788 .IX Item "-dnl,  --delete-old-newlines"
1789 By default, perltidy first deletes all old line break locations, and then it
1790 looks for good break points to match the desired line length.  Use \fB\-ndnl\fR
1791 or  \fB\-\-nodelete\-old\-newlines\fR to force perltidy to retain all old line break
1792 points.  
1793 .IP "\fB\-anl\fR,  \fB\-\-add\-newlines\fR" 4
1794 .IX Item "-anl,  --add-newlines"
1795 By default, perltidy will add line breaks when necessary to create
1796 continuations of long lines and to improve the script appearance.  Use
1797 \&\fB\-nanl\fR or \fB\-\-noadd\-newlines\fR to prevent any new line breaks.  
1798 .Sp
1799 This flag does not prevent perltidy from eliminating existing line
1800 breaks; see \fB\-\-freeze\-newlines\fR to completely prevent changes to line
1801 break points.
1802 .IP "Controlling whether perltidy breaks before or after operators" 4
1803 .IX Item "Controlling whether perltidy breaks before or after operators"
1804 Two command line parameters provide some control over whether
1805 a line break should be before or after specific token types.
1806 .Sp
1807 \&\fB\-wba=s\fR or \fB\-\-want\-break\-after=s\fR, and
1808 .Sp
1809 \&\fB\-wbb=s\fR or \fB\-\-want\-break\-before=s\fR.
1810 .Sp
1811 These parameters are each followed by a quoted string, \fBs\fR, containing
1812 a list of token types (separated only by spaces).  No more than one of each
1813 of these parameters should be specified, because repeating a
1814 command-line parameter always overwrites the previous one before
1815 perltidy ever sees it.
1816 .Sp
1817 By default, perltidy breaks \fBafter\fR these token types:
1818   % + \- * / x != == >= <= =~ !~ < >  | & >= <
1819   = **= += *= &= <<= &&= \-= /= |= >>= ||= .= %= ^= x=
1820 .Sp
1821 And perltidy breaks \fBbefore\fR these token types by default:
1822   . << >> \-> && ||
1823 .Sp
1824 To illustrate, to cause a break after a concatenation operator, \f(CW'.'\fR,
1825 rather than before it, the command line would be
1826 .Sp
1827 .Vb 1
1828 \&  \-wba="."
1829 .Ve
1830 .Sp
1831 As another example, the following command would cause a break before 
1832 math operators \f(CW'+'\fR, \f(CW'\-'\fR, \f(CW'/'\fR, and \f(CW'*'\fR:
1833 .Sp
1834 .Vb 1
1835 \&  \-wbb="+ \- / *"
1836 .Ve
1837 .Sp
1838 These commands should work well for most of the token types that perltidy uses
1839 (use \fB\-\-dump\-token\-types\fR for a list).  Also try the \-D flag on a short
1840 snippet of code and look at the .DEBUG file to see the tokenization.  However,
1841 for a few token types there may be conflicts with hardwired logic which cause
1842 unexpected results.  One example is curly braces, which should be controlled
1843 with the parameter \fBbl\fR provided for that purpose.
1844 .Sp
1845 \&\fB\s-1WARNING\s0\fR Be sure to put these tokens in quotes to avoid having them
1846 misinterpreted by your command shell.
1847 .Sh "Controlling List Formatting"
1848 .IX Subsection "Controlling List Formatting"
1849 Perltidy attempts to place comma-separated arrays of values in tables
1850 which look good.  Its default algorithms usually work well, and they
1851 have been improving with each release, but several parameters are
1852 available to control list formatting.
1853 .IP "\fB\-boc\fR,  \fB\-\-break\-at\-old\-comma\-breakpoints\fR" 4
1854 .IX Item "-boc,  --break-at-old-comma-breakpoints"
1855 This flag tells perltidy to try to break at all old commas.  This is not
1856 the default.  Normally, perltidy makes a best guess at list formatting,
1857 and seldom uses old comma breakpoints.  Usually this works well,
1858 but consider:
1859 .Sp
1860 .Vb 5
1861 \&    my @list = (1,
1862 \&                1, 1,
1863 \&                1, 2, 1,
1864 \&                1, 3, 3, 1,
1865 \&                1, 4, 6, 4, 1,);
1866 .Ve
1867 .Sp
1868 The default formatting will flatten this down to one line:
1869 .Sp
1870 .Vb 2
1871 \&    # perltidy (default)
1872 \&    my @list = ( 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1, );
1873 .Ve
1874 .Sp
1875 which hides the structure. Using \fB\-boc\fR, plus additional flags
1876 to retain the original style, yields
1877 .Sp
1878 .Vb 6
1879 \&    # perltidy \-boc \-lp \-pt=2 \-vt=1 \-vtc=1
1880 \&    my @list = (1,
1881 \&                1, 1,
1882 \&                1, 2, 1,
1883 \&                1, 3, 3, 1,
1884 \&                1, 4, 6, 4, 1,);
1885 .Ve
1886 .Sp
1887 A disadvantage of this flag is that all tables in the file
1888 must already be nicely formatted.  For another possibility see
1889 the \-fs flag in \*(L"Skipping Selected Sections of Code\*(R".
1890 .IP "\fB\-mft=n\fR,  \fB\-\-maximum\-fields\-per\-table=n\fR" 4
1891 .IX Item "-mft=n,  --maximum-fields-per-table=n"
1892 If the computed number of fields for any table exceeds \fBn\fR, then it
1893 will be reduced to \fBn\fR.  The default value for \fBn\fR is a large number,
1894 40.  While this value should probably be left unchanged as a general
1895 rule, it might be used on a small section of code to force a list to
1896 have a particular number of fields per line, and then either the \fB\-boc\fR
1897 flag could be used to retain this formatting, or a single comment could
1898 be introduced somewhere to freeze the formatting in future applications
1899 of perltidy.
1900 .Sp
1901 .Vb 9
1902 \&    # perltidy \-mft=2
1903 \&    @month_of_year = (    
1904 \&        'Jan', 'Feb',
1905 \&        'Mar', 'Apr',
1906 \&        'May', 'Jun',
1907 \&        'Jul', 'Aug',
1908 \&        'Sep', 'Oct',
1909 \&        'Nov', 'Dec'
1910 \&    );
1911 .Ve
1912 .IP "\fB\-cab=n\fR,  \fB\-\-comma\-arrow\-breakpoints=n\fR" 4
1913 .IX Item "-cab=n,  --comma-arrow-breakpoints=n"
1914 A comma which follows a comma arrow, '=>', requires special
1915 consideration.  In a long list, it is common to break at all such
1916 commas.  This parameter can be used to control how perltidy breaks at
1917 these commas.  (However, it will have no effect if old comma breaks are
1918 being forced because \fB\-boc\fR is used).  The possible values of \fBn\fR are:
1919 .Sp
1920 .Vb 6
1921 \& n=0 break at all commas after =>  
1922 \& n=1 stable: break at all commas after => unless this would break
1923 \&     an existing one\-line container (default)
1924 \& n=2 break at all commas after =>, but try to form the maximum
1925 \&     maximum one\-line container lengths
1926 \& n=3 do not treat commas after => specially at all
1927 .Ve
1928 .Sp
1929 For example, given the following single line, perltidy by default will
1930 not add any line breaks because it would break the existing one-line
1931 container:
1932 .Sp
1933 .Vb 1
1934 \&    bless { B => $B, Root => $Root } => $package;
1935 .Ve
1936 .Sp
1937 Using \fB\-cab=0\fR will force a break after each comma-arrow item:
1938 .Sp
1939 .Vb 5
1940 \&    # perltidy \-cab=0:
1941 \&    bless {
1942 \&        B    => $B,
1943 \&        Root => $Root
1944 \&    } => $package;
1945 .Ve
1946 .Sp
1947 If perltidy is subsequently run with this container broken, then by
1948 default it will break after each '=>' because the container is now
1949 broken.  To reform a one-line container, the parameter \fB\-cab=2\fR would
1950 be needed.
1951 .Sp
1952 The flag \fB\-cab=3\fR can be used to prevent these commas from being
1953 treated specially.  In this case, an item such as \*(L"01\*(R" => 31 is
1954 treated as a single item in a table.  The number of fields in this table
1955 will be determined by the same rules that are used for any other table.
1956 Here is an example.
1957 .Sp
1958 .Vb 6
1959 \&    # perltidy \-cab=3
1960 \&    my %last_day = (
1961 \&        "01" => 31, "02" => 29, "03" => 31, "04" => 30,
1962 \&        "05" => 31, "06" => 30, "07" => 31, "08" => 31,
1963 \&        "09" => 30, "10" => 31, "11" => 30, "12" => 31
1964 \&    );
1965 .Ve
1966 .Sh "Retaining or Ignoring Existing Line Breaks"
1967 .IX Subsection "Retaining or Ignoring Existing Line Breaks"
1968 Several additional parameters are available for controlling the extent
1969 to which line breaks in the input script influence the output script.
1970 In most cases, the default parameter values are set so that, if a choice
1971 is possible, the output style follows the input style.  For example, if
1972 a short logical container is broken in the input script, then the
1973 default behavior is for it to remain broken in the output script.
1974 .PP
1975 Most of the parameters in this section would only be required for a
1976 one-time conversion of a script from short container lengths to longer
1977 container lengths.  The opposite effect, of converting long container
1978 lengths to shorter lengths, can be obtained by temporarily using a short
1979 maximum line length.
1980 .IP "\fB\-bol\fR,  \fB\-\-break\-at\-old\-logical\-breakpoints\fR" 4
1981 .IX Item "-bol,  --break-at-old-logical-breakpoints"
1982 By default, if a logical expression is broken at a \f(CW\*(C`&&\*(C'\fR, \f(CW\*(C`||\*(C'\fR, \f(CW\*(C`and\*(C'\fR,
1983 or \f(CW\*(C`or\*(C'\fR, then the container will remain broken.  Also, breaks
1984 at internal keywords \f(CW\*(C`if\*(C'\fR and \f(CW\*(C`unless\*(C'\fR will normally be retained.
1985 To prevent this, and thus form longer lines, use \fB\-nbol\fR.
1986 .IP "\fB\-bok\fR,  \fB\-\-break\-at\-old\-keyword\-breakpoints\fR" 4
1987 .IX Item "-bok,  --break-at-old-keyword-breakpoints"
1988 By default, perltidy will retain a breakpoint before keywords which may
1989 return lists, such as \f(CW\*(C`sort\*(C'\fR and <map>.  This allows chains of these
1990 operators to be displayed one per line.  Use \fB\-nbok\fR to prevent
1991 retaining these breakpoints.
1992 .IP "\fB\-bot\fR,  \fB\-\-break\-at\-old\-trinary\-breakpoints\fR" 4
1993 .IX Item "-bot,  --break-at-old-trinary-breakpoints"
1994 By default, if a conditional (trinary) operator is broken at a \f(CW\*(C`:\*(C'\fR,
1995 then it will remain broken.  To prevent this, and thereby
1996 form longer lines, use \fB\-nbot\fR.
1997 .IP "\fB\-iob\fR,  \fB\-\-ignore\-old\-breakpoints\fR" 4
1998 .IX Item "-iob,  --ignore-old-breakpoints"
1999 Use this flag to tell perltidy to ignore existing line breaks to the
2000 maximum extent possible.  This will tend to produce the longest possible
2001 containers, regardless of type, which do not exceed the line length
2002 limit.
2003 .Sh "Blank Line Control"
2004 .IX Subsection "Blank Line Control"
2005 Blank lines can improve the readability of a script if they are carefully
2006 placed.  Perltidy has several commands for controlling the insertion,
2007 retention, and removal of blank lines.
2008 .IP "\fB\-bbc\fR,  \fB\-\-blanks\-before\-comments\fR" 4
2009 .IX Item "-bbc,  --blanks-before-comments"
2010 A blank line will be introduced before a full-line comment.  This is the
2011 default.  Use \fB\-nbbc\fR or  \fB\-\-noblanks\-before\-comments\fR to prevent
2012 such blank lines from being introduced.
2013 .IP "\fB\-bbs\fR,  \fB\-\-blanks\-before\-subs\fR" 4
2014 .IX Item "-bbs,  --blanks-before-subs"
2015 A blank line will be introduced before a \fBsub\fR definition, unless it is a
2016 one-liner or preceded by a comment.  A blank line will also be introduced
2017 before a \fBpackage\fR statement and a \fB\s-1BEGIN\s0\fR and \fB\s-1END\s0\fR block.  This is the
2018 default.  The intention is to help display the structure of a program by
2019 setting off certain key sections of code.  This is negated with \fB\-nbbs\fR or
2020 \&\fB\-\-noblanks\-before\-subs\fR.  
2021 .IP "\fB\-bbb\fR,  \fB\-\-blanks\-before\-blocks\fR" 4
2022 .IX Item "-bbb,  --blanks-before-blocks"
2023 A blank line will be introduced before blocks of coding delimited by
2024 \&\fBfor\fR, \fBforeach\fR, \fBwhile\fR, \fBuntil\fR, and \fBif\fR, \fBunless\fR, in the following
2025 circumstances:
2026 .RS 4
2027 .IP "*" 4
2028 The block is not preceded by a comment.
2029 .IP "*" 4
2030 The block is not a one-line block.
2031 .IP "*" 4
2032 The number of consecutive non-blank lines at the current indentation depth is at least \fB\-lbl\fR
2033 (see next section).
2034 .RE
2035 .RS 4
2036 .Sp
2037 This is the default.  The intention of this option is to introduce
2038 some space within dense coding.
2039 This is negated with \fB\-nbbb\fR or  \fB\-\-noblanks\-before\-blocks\fR.
2040 .RE
2041 .IP "\fB\-lbl=n\fR \fB\-\-long\-block\-line\-count=n\fR" 4
2042 .IX Item "-lbl=n --long-block-line-count=n"
2043 This controls how often perltidy is allowed to add blank lines before 
2044 certain block types (see previous section).  The default is 8.  Entering
2045 a value of \fB0\fR is equivalent to entering a very large number.
2046 .IP "\fB\-mbl=n\fR \fB\-\-maximum\-consecutive\-blank\-lines=n\fR" 4
2047 .IX Item "-mbl=n --maximum-consecutive-blank-lines=n"
2048 This parameter specifies the maximum number of consecutive blank lines
2049 in the output script.  The default is n=1.  If the input file has more
2050 than n consecutive blank lines, the number will be reduced to n.
2051 (This obviously does not apply to pod sections, here\-documents, and quotes).
2052 .IP "\fB\-sob\fR,  \fB\-\-swallow\-optional\-blank\-lines\fR" 4
2053 .IX Item "-sob,  --swallow-optional-blank-lines"
2054 All blank lines not required by the above flags, \fB\-bbb\fR, \fB\-bbs\fR, and \fB\-bbc\fR,
2055 will be deleted.  (But essential blank lines above pod documents will be
2056 retained).  This is \s-1NOT\s0 the default.
2057 .IP "\fB\-nsob\fR,  \fB\-\-noswallow\-optional\-blank\-lines\fR" 4
2058 .IX Item "-nsob,  --noswallow-optional-blank-lines"
2059 Retain blank lines, including those which do not corresponding to flags
2060 \&\fB\-bbb\fR, \fB\-bbs\fR, and \fB\-bbc\fR.  This is the default.  The number of
2061 blanks retained is subject to the limit imposed by
2062 \&\fB\-\-maximum\-consecutive\-blank\-lines\fR, however.
2063 .Sh "Styles"
2064 .IX Subsection "Styles"
2065 A style refers to a convenient collection of existing parameters.
2066 .IP "\fB\-gnu\fR, \fB\-\-gnu\-style\fR" 4
2067 .IX Item "-gnu, --gnu-style"
2068 \&\fB\-gnu\fR gives an approximation to the \s-1GNU\s0 Coding Standards (which do
2069 not apply to perl) as they are sometimes implemented.  At present, this
2070 style overrides the default style with the following parameters:
2071 .Sp
2072 .Vb 1
2073 \&    \-lp \-bl \-noll \-pt=2 \-bt=2 \-sbt=2 \-icp
2074 .Ve
2075 .Sh "Other Controls"
2076 .IX Subsection "Other Controls"
2077 .IP "Deleting selected text" 4
2078 .IX Item "Deleting selected text"
2079 Perltidy can selectively delete comments and/or pod documentation.  The
2080 command \fB\-dac\fR or  \fB\-\-delete\-all\-comments\fR will delete all comments
2081 \&\fBand\fR all pod documentation, leaving just code and any leading system
2082 control lines.
2083 .Sp
2084 The command \fB\-dp\fR or \fB\-\-delete\-pod\fR will remove all pod documentation
2085 (but not comments).
2086 .Sp
2087 Two commands which remove comments (but not pod) are: \fB\-dbc\fR or
2088 \&\fB\-\-delete\-block\-comments\fR and \fB\-dsc\fR or  \fB\-\-delete\-side\-comments\fR.
2089 (Hanging side comments will be deleted with block comments here.)
2090 .Sp
2091 The negatives of these commands also work, and are the defaults.  When
2092 block comments are deleted, any leading 'hash\-bang' will be retained.
2093 Also, if the \fB\-x\fR flag is used, any system commands before a leading
2094 hash-bang will be retained (even if they are in the form of comments).
2095 .IP "Writing selected text to a file" 4
2096 .IX Item "Writing selected text to a file"
2097 When perltidy writes a formatted text file, it has the ability to also
2098 send selected text to a file with a \fI.TEE\fR extension.  This text can
2099 include comments and pod documentation.  
2100 .Sp
2101 The command \fB\-tac\fR or  \fB\-\-tee\-all\-comments\fR will write all comments
2102 \&\fBand\fR all pod documentation.
2103 .Sp
2104 The command \fB\-tp\fR or \fB\-\-tee\-pod\fR will write all pod documentation (but
2105 not comments).
2106 .Sp
2107 The commands which write comments (but not pod) are: \fB\-tbc\fR or
2108 \&\fB\-\-tee\-block\-comments\fR and \fB\-tsc\fR or  \fB\-\-tee\-side\-comments\fR.
2109 (Hanging side comments will be written with block comments here.)
2110 .Sp
2111 The negatives of these commands also work, and are the defaults.  
2112 .IP "Using a \fI.perltidyrc\fR command file" 4
2113 .IX Item "Using a .perltidyrc command file"
2114 If you use perltidy frequently, you probably won't be happy until you
2115 create a \fI.perltidyrc\fR file to avoid typing commonly-used parameters.
2116 Perltidy will first look in your current directory for a command file
2117 named \fI.perltidyrc\fR.  If it does not find one, it will continue looking
2118 for one in other standard locations.  
2119 .Sp
2120 These other locations are system\-dependent, and may be displayed with
2121 the command \f(CW\*(C`perltidy \-dpro\*(C'\fR.  Under Unix systems, it will look for a
2122 \&\fI.perltidyrc\fR file in the home directory, and then for a system-wide
2123 file \fI/usr/local/etc/perltidyrc\fR, and then it will look for
2124 \&\fI/etc/perltidyrc\fR.  Note that these last two system-wide files do not
2125 have a leading dot.  Further system-dependent information will be found
2126 in the \s-1INSTALL\s0 file distributed with perltidy.
2127 .Sp
2128 This file is free format, and simply a list of parameters, just as they
2129 would be entered on a command line.  Any number of lines may be used,
2130 with any number of parameters per line, although it may be easiest to
2131 read with one parameter per line.  Blank lines are ignored, and text
2132 after a '#' is ignored to the end of a line.
2133 .Sp
2134 Here is an example of a \fI.perltidyrc\fR file:
2135 .Sp
2136 .Vb 8
2137 \&  # This is a simple of a .perltidyrc configuration file
2138 \&  # This implements a highly spaced style
2139 \&  \-se    # errors to standard error output
2140 \&  \-w     # show all warnings
2141 \&  \-bl    # braces on new lines
2142 \&  \-pt=0  # parens not tight at all
2143 \&  \-bt=0  # braces not tight
2144 \&  \-sbt=0 # square brackets not tight
2145 .Ve
2146 .Sp
2147 The parameters in the \fI.perltidyrc\fR file are installed first, so any
2148 parameters given on the command line will have priority over them.  
2149 .Sp
2150 To avoid confusion, perltidy ignores any command in the .perltidyrc
2151 file which would cause some kind of dump and an exit.  These are:
2152 .Sp
2153 .Vb 1
2154 \& \-h \-v \-ddf \-dln \-dop \-dsn \-dtt \-dwls \-dwrs \-ss
2155 .Ve
2156 .Sp
2157 There are several options may be helpful in debugging a \fI.perltidyrc\fR
2158 file:  
2159 .RS 4
2160 .IP "*" 4
2161 A very helpful command is \fB\-\-dump\-profile\fR or \fB\-dpro\fR.  It writes a
2162 list of all configuration filenames tested to standard output, and 
2163 if a file is found, it dumps the content to standard output before
2164 exiting.  So, to find out where perltidy looks for its configuration
2165 files, and which one if any it selects, just enter 
2166 .Sp
2167 .Vb 1
2168 \&  perltidy \-dpro
2169 .Ve
2170 .IP "*" 4
2171 It may be simplest to develop and test configuration files with
2172 alternative names, and invoke them with \fB\-pro=filename\fR on the command
2173 line.  Then rename the desired file to \fI.perltidyrc\fR when finished.
2174 .IP "*" 4
2175 The parameters in the \fI.perltidyrc\fR file can be switched off with 
2176 the \fB\-npro\fR option.
2177 .IP "*" 4
2178 The commands \fB\-\-dump\-options\fR, \fB\-\-dump\-defaults\fR, \fB\-\-dump\-long\-names\fR,
2179 and \fB\-\-dump\-short\-names\fR, all described below, may all be helpful.
2180 .RE
2181 .RS 4
2182 .RE
2183 .IP "Creating a new abbreviation" 4
2184 .IX Item "Creating a new abbreviation"
2185 A special notation is available for use in a \fI.perltidyrc\fR file
2186 for creating an abbreviation for a group
2187 of options.  This can be used to create a
2188 shorthand for one or more styles which are frequently, but not always,
2189 used.  The notation is to group the options within curly braces which
2190 are preceded by the name of the alias (without leading dashes), like this:
2191 .Sp
2192 .Vb 4
2193 \&        newword {
2194 \&        \-opt1
2195 \&        \-opt2
2196 \&        }
2197 .Ve
2198 .Sp
2199 where \fBnewword\fR is the abbreviation, and \fBopt1\fR, etc, are existing parameters
2200 \&\fIor other abbreviations\fR.  The main syntax requirement is that
2201 the new abbreviation must begin on a new line.
2202 Space before and after the curly braces is optional.
2203 For a
2204 specific example, the following line
2205 .Sp
2206 .Vb 1
2207 \&        airy {\-bl \-pt=0 \-bt=0 \-sbt=0}
2208 .Ve
2209 .Sp
2210 could be placed in a \fI.perltidyrc\fR file, and then invoked at will with
2211 .Sp
2212 .Vb 1
2213 \&        perltidy \-airy somefile.pl
2214 .Ve
2215 .Sp
2216 (Either \f(CW\*(C`\-airy\*(C'\fR or \f(CW\*(C`\-\-airy\*(C'\fR may be used).
2217 .IP "Skipping leading non-perl commands with \fB\-x\fR or \fB\-\-look\-for\-hash\-bang\fR" 4
2218 .IX Item "Skipping leading non-perl commands with -x or --look-for-hash-bang"
2219 If your script has leading lines of system commands or other text which
2220 are not valid perl code, and which are separated from the start of the
2221 perl code by a \*(L"hash\-bang\*(R" line, ( a line of the form \f(CW\*(C`#!...perl\*(C'\fR ),
2222 you must use the \fB\-x\fR flag to tell perltidy not to parse and format any
2223 lines before the \*(L"hash\-bang\*(R" line.  This option also invokes perl with a
2224 \&\-x flag when checking the syntax.  This option was originally added to
2225 allow perltidy to parse interactive \s-1VMS\s0 scripts, but it should be used
2226 for any script which is normally invoked with \f(CW\*(C`perl \-x\*(C'\fR.
2227 .IP "Making a file unreadable" 4
2228 .IX Item "Making a file unreadable"
2229 The goal of perltidy is to improve the readability of files, but there
2230 are two commands which have the opposite effect, \fB\-\-mangle\fR and
2231 \&\fB\-\-extrude\fR.  They are actually
2232 merely aliases for combinations of other parameters.  Both of these
2233 strip all possible whitespace, but leave comments and pod documents,
2234 so that they are essentially reversible.  The
2235 difference between these is that \fB\-\-mangle\fR puts the fewest possible
2236 line breaks in a script while \fB\-\-extrude\fR puts the maximum possible.
2237 Note that these options do not provided any meaningful obfuscation, because
2238 perltidy can be used to reformat the files.  They were originally
2239 developed to help test the tokenization logic of perltidy, but they
2240 have other uses.
2241 One use for \fB\-\-mangle\fR is the following:
2242 .Sp
2243 .Vb 1
2244 \&  perltidy \-\-mangle myfile.pl \-st | perltidy \-o myfile.pl.new
2245 .Ve
2246 .Sp
2247 This will form the maximum possible number of one-line blocks (see next
2248 section), and can sometimes help clean up a badly formatted script.
2249 .Sp
2250 A similar technique can be used with \fB\-\-extrude\fR instead of \fB\-\-mangle\fR
2251 to make the minimum number of one-line blocks.
2252 .Sp
2253 Another use for \fB\-\-mangle\fR is to combine it with \fB\-dac\fR to reduce
2254 the file size of a perl script.
2255 .IP "One-line blocks" 4
2256 .IX Item "One-line blocks"
2257 There are a few points to note regarding one-line blocks.  A one-line
2258 block is something like this,
2259 .Sp
2260 .Vb 1
2261 \&        if ($x > 0) { $y = 1 / $x }
2262 .Ve
2263 .Sp
2264 where the contents within the curly braces is short enough to fit
2265 on a single line.
2266 .Sp
2267 With few exceptions, perltidy retains existing one-line blocks, if it
2268 is possible within the line-length constraint, but it does not attempt
2269 to form new ones.  In other words, perltidy will try to follow the
2270 one-line block style of the input file.
2271 .Sp
2272 If an existing one-line block is longer than the maximum line length,
2273 however, it will be broken into multiple lines.  When this happens, perltidy
2274 checks for and adds any optional terminating semicolon (unless the \fB\-nasc\fR
2275 option is used) if the block is a code block.  
2276 .Sp
2277 The main exception is that perltidy will attempt to form new one-line
2278 blocks following the keywords \f(CW\*(C`map\*(C'\fR, \f(CW\*(C`eval\*(C'\fR, and \f(CW\*(C`sort\*(C'\fR, because
2279 these code blocks are often small and most clearly displayed in a single
2280 line.
2281 .Sp
2282 One-line block rules can conflict with the cuddled-else option.  When
2283 the cuddled-else option is used, perltidy retains existing one-line
2284 blocks, even if they do not obey cuddled-else formatting.
2285 .Sp
2286 Occasionally, when one-line blocks get broken because they exceed the
2287 available line length, the formatting will violate the requested brace style.
2288 If this happens, reformatting the script a second time should correct
2289 the problem.
2290 .IP "Debugging" 4
2291 .IX Item "Debugging"
2292 The following flags are available for debugging:
2293 .Sp
2294 \&\fB\-\-dump\-defaults\fR or \fB\-ddf\fR will write the default option set to standard output and quit
2295 .Sp
2296 \&\fB\-\-dump\-profile\fR or \fB\-dpro\fR  will write the name of the current 
2297 configuration file and its contents to standard output and quit.
2298 .Sp
2299 \&\fB\-\-dump\-options\fR or \fB\-dop\fR  will write current option set to standard
2300 output and quit.  
2301 .Sp
2302 \&\fB\-\-dump\-long\-names\fR or \fB\-dln\fR  will write all command line long names (passed 
2303 to Get_options) to standard output and quit.
2304 .Sp
2305 \&\fB\-\-dump\-short\-names\fR  or \fB\-dsn\fR will write all command line short names 
2306 to standard output and quit.
2307 .Sp
2308 \&\fB\-\-dump\-token\-types\fR or \fB\-dtt\fR  will write a list of all token types 
2309 to standard output and quit.
2310 .Sp
2311 \&\fB\-\-dump\-want\-left\-space\fR or \fB\-dwls\fR  will write the hash \f(CW%want_left_space\fR
2312 to standard output and quit.  See the section on controlling whitespace
2313 around tokens.
2314 .Sp
2315 \&\fB\-\-dump\-want\-right\-space\fR or \fB\-dwrs\fR  will write the hash \f(CW%want_right_space\fR
2316 to standard output and quit.  See the section on controlling whitespace
2317 around tokens.
2318 .Sp
2319 \&\fB\-DEBUG\fR  will write a file with extension \fI.DEBUG\fR for each input file 
2320 showing the tokenization of all lines of code.
2321 .IP "Working with MakeMaker, AutoLoader and SelfLoader" 4
2322 .IX Item "Working with MakeMaker, AutoLoader and SelfLoader"
2323 The first \f(CW$VERSION\fR line of a file which might be eval'd by MakeMaker
2324 is passed through unchanged except for indentation.  
2325 Use \fB\-\-nopass\-version\-line\fR, or \fB\-npvl\fR, to deactivate this feature.
2326 .Sp
2327 If the AutoLoader module is used, perltidy will continue formatting
2328 code after seeing an _\|_END_\|_ line.
2329 Use \fB\-\-nolook\-for\-autoloader\fR, or \fB\-nlal\fR, to deactivate this feature.
2330 .Sp
2331 Likewise, if the SelfLoader module is used, perltidy will continue formatting
2332 code after seeing a _\|_DATA_\|_ line.
2333 Use \fB\-\-nolook\-for\-selfloader\fR, or \fB\-nlsl\fR, to deactivate this feature.
2334 .IP "Working around problems with older version of Perl" 4
2335 .IX Item "Working around problems with older version of Perl"
2336 Perltidy contains a number of rules which help avoid known subtleties
2337 and problems with older versions of perl, and these rules always
2338 take priority over whatever formatting flags have been set.  For example,
2339 perltidy will usually avoid starting a new line with a bareword, because
2340 this might cause problems if \f(CW\*(C`use strict\*(C'\fR is active.
2341 .Sp
2342 There is no way to override these rules.
2343 .SH "HTML OPTIONS"
2344 .IX Header "HTML OPTIONS"
2345 .IP "The \fB\-html\fR master switch" 4
2346 .IX Item "The -html master switch"
2347 The flag \fB\-html\fR causes perltidy to write an html file with extension
2348 \&\fI.html\fR.  So, for example, the following command
2349 .Sp
2350 .Vb 1
2351 \&        perltidy \-html somefile.pl
2352 .Ve
2353 .Sp
2354 will produce a syntax-colored html file named \fIsomefile.pl.html\fR
2355 which may be viewed with a browser.
2356 .Sp
2357 \&\fBPlease Note\fR: In this case, perltidy does not do any formatting to the
2358 input file, and it does not write a formatted file with extension
2359 \&\fI.tdy\fR.  This means that two perltidy runs are required to create a
2360 fully reformatted, html copy of a script.  
2361 .IP "The \fB\-pre\fR flag for code snippets" 4
2362 .IX Item "The -pre flag for code snippets"
2363 When the \fB\-pre\fR flag is given, only the pre-formatted section, within
2364 the <\s-1PRE\s0> and </PRE> tags, will be output.  This simplifies inclusion
2365 of the output in other files.  The default is to output a complete
2366 web page.
2367 .IP "The \fB\-nnn\fR flag for line numbering" 4
2368 .IX Item "The -nnn flag for line numbering"
2369 When the \fB\-nnn\fR flag is given, the output lines will be numbered.
2370 .IP "The \fB\-toc\fR, or \fB\-\-html\-table\-of\-contents\fR flag" 4
2371 .IX Item "The -toc, or --html-table-of-contents flag"
2372 By default, a table of contents to packages and subroutines will be
2373 written at the start of html output.  Use \fB\-ntoc\fR to prevent this.
2374 This might be useful, for example, for a pod document which contains a
2375 number of unrelated code snippets.  This flag only influences the code
2376 table of contents; it has no effect on any table of contents produced by
2377 pod2html (see next item).
2378 .IP "The \fB\-pod\fR, or \fB\-\-pod2html\fR flag" 4
2379 .IX Item "The -pod, or --pod2html flag"
2380 There are two options for formatting pod documentation.  The default is
2381 to pass the pod through the Pod::Html module (which forms the basis of
2382 the pod2html utility).  Any code sections are formatted by perltidy, and
2383 the results then merged.  Note: perltidy creates a temporary file when
2384 Pod::Html is used; see \*(L"\s-1FILES\s0\*(R".  Also, Pod::Html creates temporary
2385 files for its cache.
2386 .Sp
2387 \&\s-1NOTE:\s0 Perltidy counts the number of \f(CW\*(C`=cut\*(C'\fR lines, and either moves the
2388 pod text to the top of the html file if there is one \f(CW\*(C`=cut\*(C'\fR, or leaves
2389 the pod text in its original order (interleaved with code) otherwise.
2390 .Sp
2391 Most of the flags accepted by pod2html may be included in the perltidy
2392 command line, and they will be passed to pod2html.  In some cases,
2393 the flags have a prefix \f(CW\*(C`pod\*(C'\fR to emphasize that they are for the
2394 pod2html, and this prefix will be removed before they are passed to
2395 pod2html.  The flags which have the additional \f(CW\*(C`pod\*(C'\fR prefix are:
2396 .Sp
2397 .Vb 2
2398 \&   \-\-[no]podheader \-\-[no]podindex \-\-[no]podrecurse \-\-[no]podquiet 
2399 \&   \-\-[no]podverbose \-\-podflush
2400 .Ve
2401 .Sp
2402 The flags which are unchanged from their use in pod2html are:
2403 .Sp
2404 .Vb 2
2405 \&   \-\-backlink=s \-\-cachedir=s \-\-htmlroot=s \-\-libpods=s \-\-title=s
2406 \&   \-\-podpath=s \-\-podroot=s
2407 .Ve
2408 .Sp
2409 where 's' is an appropriate character string.  Not all of these flags are
2410 available in older versions of Pod::Html.  See your Pod::Html documentation for
2411 more information.
2412 .Sp
2413 The alternative, indicated with \fB\-npod\fR, is not to use Pod::Html, but
2414 rather to format pod text in italics (or whatever the stylesheet
2415 indicates), without special html markup.  This is useful, for example,
2416 if pod is being used as an alternative way to write comments.
2417 .IP "The \fB\-frm\fR, or \fB\-\-frames\fR flag" 4
2418 .IX Item "The -frm, or --frames flag"
2419 By default, a single html output file is produced.  This can be changed
2420 with the \fB\-frm\fR option, which creates a frame holding a table of
2421 contents in the left panel and the source code in the right side. This
2422 simplifies code browsing.  Assume, for example, that the input file is
2423 \&\fIMyModule.pm\fR.  Then, for default file extension choices, these three
2424 files will be created:
2425 .Sp
2426 .Vb 3
2427 \& MyModule.pm.html      \- the frame
2428 \& MyModule.pm.toc.html  \- the table of contents
2429 \& MyModule.pm.src.html  \- the formatted source code
2430 .Ve
2431 .Sp
2432 Obviously this file naming scheme requires that output be directed to a real
2433 file (as opposed to, say, standard output).  If this is not the
2434 case, or if the file extension is unknown, the \fB\-frm\fR option will be
2435 ignored.
2436 .IP "The \fB\-text=s\fR, or \fB\-\-html\-toc\-extension\fR flag" 4
2437 .IX Item "The -text=s, or --html-toc-extension flag"
2438 Use this flag to specify the extra file extension of the table of contents file
2439 when html frames are used.  The default is \*(L"toc\*(R".
2440 See \*(L"Specifying File Extensions\*(R".
2441 .IP "The \fB\-sext=s\fR, or \fB\-\-html\-src\-extension\fR flag" 4
2442 .IX Item "The -sext=s, or --html-src-extension flag"
2443 Use this flag to specify the extra file extension of the content file when html
2444 frames are used.  The default is \*(L"src\*(R".
2445 See \*(L"Specifying File Extensions\*(R".
2446 .IP "The \fB\-hent\fR, or \fB\-\-html\-entities\fR flag" 4
2447 .IX Item "The -hent, or --html-entities flag"
2448 This flag controls the use of Html::Entities for html formatting.  By
2449 default, the module Html::Entities is used to encode special symbols.
2450 This may not be the right thing for some browser/language
2451 combinations.  Use \-\-nohtml\-entities or \-nhent to prevent this.
2452 .IP "Style Sheets" 4
2453 .IX Item "Style Sheets"
2454 Style sheets make it very convenient to control and adjust the
2455 appearance of html pages.  The default behavior is to write a page of
2456 html with an embedded style sheet.
2457 .Sp
2458 An alternative to an embedded style sheet is to create a page with a
2459 link to an external style sheet.  This is indicated with the
2460 \&\fB\-css=filename\fR,  where the external style sheet is \fIfilename\fR.  The
2461 external style sheet \fIfilename\fR will be created if and only if it does
2462 not exist.  This option is useful for controlling multiple pages from a
2463 single style sheet.
2464 .Sp
2465 To cause perltidy to write a style sheet to standard output and exit,
2466 use the \fB\-ss\fR, or \fB\-\-stylesheet\fR, flag.  This is useful if the style
2467 sheet could not be written for some reason, such as if the \fB\-pre\fR flag
2468 was used.  Thus, for example,
2469 .Sp
2470 .Vb 1
2471 \&  perltidy \-html \-ss >mystyle.css
2472 .Ve
2473 .Sp
2474 will write a style sheet with the default properties to file
2475 \&\fImystyle.css\fR.
2476 .Sp
2477 The use of style sheets is encouraged, but a web page without a style
2478 sheets can be created with the flag \fB\-nss\fR.  Use this option if you
2479 must to be sure that older browsers (roughly speaking, versions prior to
2480 4.0 of Netscape Navigator and Internet Explorer) can display the
2481 syntax-coloring of the html files.
2482 .IP "Controlling \s-1HTML\s0 properties" 4
2483 .IX Item "Controlling HTML properties"
2484 Note: It is usually more convenient to accept the default properties
2485 and then edit the stylesheet which is produced.  However, this section
2486 shows how to control the properties with flags to perltidy.
2487 .Sp
2488 Syntax colors may be changed from their default values by flags of the either
2489 the long form, \fB\-html\-color\-xxxxxx=n\fR, or more conveniently the short form,
2490 \&\fB\-hcx=n\fR, where \fBxxxxxx\fR is one of the following words, and \fBx\fR is the
2491 corresponding abbreviation:
2492 .Sp
2493 .Vb 19
2494 \&      Token Type             xxxxxx           x 
2495 \&      \-\-\-\-\-\-\-\-\-\-             \-\-\-\-\-\-\-\-         \-\-
2496 \&      comment                comment          c
2497 \&      number                 numeric          n
2498 \&      identifier             identifier       i
2499 \&      bareword, function     bareword         w
2500 \&      keyword                keyword          k
2501 \&      quite, pattern         quote            q
2502 \&      here doc text          here\-doc\-text    h
2503 \&      here doc target        here\-doc\-target  hh
2504 \&      punctuation            punctuation      pu
2505 \&      parentheses            paren            p
2506 \&      structural braces      structure        s
2507 \&      semicolon              semicolon        sc
2508 \&      colon                  colon            co
2509 \&      comma                  comma            cm
2510 \&      label                  label            j
2511 \&      sub definition name    subroutine       m
2512 \&      pod text               pod\-text         pd
2513 .Ve
2514 .Sp
2515 A default set of colors has been defined, but they may be changed by providing
2516 values to any of the following parameters, where \fBn\fR is either a 6 digit 
2517 hex \s-1RGB\s0 color value or an ascii name for a color, such as 'red'.
2518 .Sp
2519 To illustrate, the following command will produce an html 
2520 file \fIsomefile.pl.html\fR with \*(L"aqua\*(R" keywords:
2521 .Sp
2522 .Vb 1
2523 \&        perltidy \-html \-hck=00ffff somefile.pl
2524 .Ve
2525 .Sp
2526 and this should be equivalent for most browsers:
2527 .Sp
2528 .Vb 1
2529 \&        perltidy \-html \-hck=aqua somefile.pl
2530 .Ve
2531 .Sp
2532 Perltidy merely writes any non-hex names that it sees in the html file.
2533 The following 16 color names are defined in the \s-1HTML\s0 3.2 standard:
2534 .Sp
2535 .Vb 16
2536 \&        black   => 000000,
2537 \&        silver  => c0c0c0,
2538 \&        gray    => 808080,
2539 \&        white   => ffffff,
2540 \&        maroon  => 800000,
2541 \&        red     => ff0000,
2542 \&        purple  => 800080,
2543 \&        fuchsia => ff00ff,
2544 \&        green   => 008000,
2545 \&        lime    => 00ff00,
2546 \&        olive   => 808000,
2547 \&        yellow  => ffff00
2548 \&        navy    => 000080,
2549 \&        blue    => 0000ff,
2550 \&        teal    => 008080,
2551 \&        aqua    => 00ffff,
2552 .Ve
2553 .Sp
2554 Many more names are supported in specific browsers, but it is safest
2555 to use the hex codes for other colors.  Helpful color tables can be
2556 located with an internet search for \*(L"\s-1HTML\s0 color tables\*(R". 
2557 .Sp
2558 Besides color, two other character attributes may be set: bold, and italics.
2559 To set a token type to use bold, use the flag
2560 \&\fB\-\-html\-bold\-xxxxxx\fR or \fB\-hbx\fR, where \fBxxxxxx\fR or \fBx\fR are the long
2561 or short names from the above table.  Conversely, to set a token type to 
2562 \&\s-1NOT\s0 use bold, use \fB\-\-nohtml\-bold\-xxxxxx\fR or \fB\-nhbx\fR.
2563 .Sp
2564 Likewise, to set a token type to use an italic font, use the flag
2565 \&\fB\-\-html\-italic\-xxxxxx\fR or \fB\-hix\fR, where again \fBxxxxxx\fR or \fBx\fR are the
2566 long or short names from the above table.  And to set a token type to
2567 \&\s-1NOT\s0 use italics, use \fB\-\-nohtml\-italic\-xxxxxx\fR or \fB\-nhix\fR.
2568 .Sp
2569 For example, to use bold braces and lime color, non\-bold, italics keywords the
2570 following command would be used:
2571 .Sp
2572 .Vb 1
2573 \&        perltidy \-html \-hbs \-hck=00FF00 \-nhbk \-hik somefile.pl
2574 .Ve
2575 .Sp
2576 The background color can be specified with \fB\-\-html\-color\-background=n\fR,
2577 or \fB\-hcbg=n\fR for short, where n is a 6 character hex \s-1RGB\s0 value.  The
2578 default color of text is the value given to \fBpunctuation\fR, which is
2579 black as a default.
2580 .Sp
2581 Here are some notes and hints:
2582 .Sp
2583 1. If you find a preferred set of these parameters, you may want
2584 to create a \fI.perltidyrc\fR file containing them.  See the perltidy man
2585 page for an explanation.
2586 .Sp
2587 2. Rather than specifying values for these parameters, it is probably
2588 easier to accept the defaults and then edit a style sheet.  The style
2589 sheet contains comments which should make this easy.
2590 .Sp
2591 3. The syntax-colored html files can be very large, so it may be best to
2592 split large files into smaller pieces to improve download times.
2593 .SH "SOME COMMON INPUT CONVENTIONS"
2594 .IX Header "SOME COMMON INPUT CONVENTIONS"
2595 .Sh "Specifying Block Types"
2596 .IX Subsection "Specifying Block Types"
2597 Several parameters which refer to code block types may be customized by also
2598 specifying an associated list of block types.  The type of a block is the name
2599 of the keyword which introduces that block, such as \fBif\fR, \fBelse\fR, or \fBsub\fR.
2600 An exception is a labeled block, which has no keyword, and should be specified
2601 with just a colon.
2602 .PP
2603 For example, the following parameter specifies \f(CW\*(C`sub\*(C'\fR, labels, \f(CW\*(C`BEGIN\*(C'\fR, and
2604 \&\f(CW\*(C`END\*(C'\fR blocks:
2605 .PP
2606 .Vb 1
2607 \&   \-cscl="sub : BEGIN END"
2608 .Ve
2609 .PP
2610 (the meaning of the \-cscl parameter is described above.)  Note that
2611 quotes are required around the list of block types because of the
2612 spaces.
2613 .Sh "Specifying File Extensions"
2614 .IX Subsection "Specifying File Extensions"
2615 Several parameters allow default file extensions to be overridden.  For
2616 example, a backup file extension may be specified with \fB\-bext=ext\fR,
2617 where \fBext\fR is some new extension.  In order to provides the user some
2618 flexibility, the following convention is used in all cases to decide if
2619 a leading '.' should be used.  If the extension \f(CW\*(C`ext\*(C'\fR begins with
2620 \&\f(CW\*(C`A\-Z\*(C'\fR, \f(CW\*(C`a\-z\*(C'\fR, or \f(CW\*(C`0\-9\*(C'\fR, then it will be appended to the filename with
2621 an intermediate '.' (or perhaps an '_' on \s-1VMS\s0 systems).  Otherwise, it
2622 will be appended directly.  
2623 .PP
2624 For example, suppose the file is \fIsomefile.pl\fR.  For \f(CW\*(C`\-bext=old\*(C'\fR, a '.' is
2625 added to give \fIsomefile.pl.old\fR.  For \f(CW\*(C`\-bext=.old\*(C'\fR, no additional '.' is
2626 added, so again the backup file is \fIsomefile.pl.old\fR.  For \f(CW\*(C`\-bext=~\*(C'\fR, then no
2627 dot is added, and the backup file will be \fIsomefile.pl~\fR  .  
2628 .SH "SWITCHES WHICH MAY BE NEGATED"
2629 .IX Header "SWITCHES WHICH MAY BE NEGATED"
2630 The following list shows all short parameter names which allow a prefix
2631 \&'n' to produce the negated form:
2632 .PP
2633 .Vb 6
2634 \& D    anl asc  aws  b    bbb bbc bbs  bl   bli  boc bok  bol  bot  ce
2635 \& csc  dac dbc  dcsc ddf  dln dnl dop  dp   dpro dsc dsm  dsn  dtt  dwls
2636 \& dwrs dws f    fll  frm  fs  hsc html ibc  icb  icp iob  isbc lal  log
2637 \& lp   lsl ohbr okw  ola  oll opr opt  osbr otr  ple ple  pod  pvl  q
2638 \& sbc  sbl schb scp  scsb sct se  sfp  sfs  skp  sob sohb sop  sosb sot
2639 \& ssc  st  sts  syn  t    tac tbc toc  tp   tqw  tsc w    x
2640 .Ve
2641 .PP
2642 Equivalently, the prefix 'no' or 'no\-' on the corresponding long names may be
2643 used.
2644 .SH "LIMITATIONS"
2645 .IX Header "LIMITATIONS"
2646 .IP "Parsing Limitations" 4
2647 .IX Item "Parsing Limitations"
2648 Perltidy should work properly on most perl scripts.  It does a lot of
2649 self\-checking, but still, it is possible that an error could be
2650 introduced and go undetected.  Therefore, it is essential to make
2651 careful backups and to test reformatted scripts.
2652 .Sp
2653 The main current limitation is that perltidy does not scan modules
2654 included with 'use' statements.  This makes it necessary to guess the
2655 context of any bare words introduced by such modules.  Perltidy has good
2656 guessing algorithms, but they are not infallible.  When it must guess,
2657 it leaves a message in the log file.
2658 .Sp
2659 If you encounter a bug, please report it.
2660 .IP "What perltidy does not parse and format" 4
2661 .IX Item "What perltidy does not parse and format"
2662 Perltidy indents but does not reformat comments and \f(CW\*(C`qw\*(C'\fR quotes. 
2663 Perltidy does not in any way modify the contents of here documents or
2664 quoted text, even if they contain source code.  (You could, however,
2665 reformat them separately).  Perltidy does not format 'format' sections
2666 in any way.  And, of course, it does not modify pod documents.
2667 .SH "FILES"
2668 .IX Header "FILES"
2669 .IP "Temporary files" 4
2670 .IX Item "Temporary files"
2671 Under the \-html option with the default \-\-pod2html flag, a temporary file is
2672 required to pass text to Pod::Html.  Unix systems will try to use the \s-1POSIX\s0
2673 \&\fItmpnam()\fR function.  Otherwise the file \fIperltidy.TMP\fR will be temporarily
2674 created in the current working directory.
2675 .IP "Special files when standard input is used" 4
2676 .IX Item "Special files when standard input is used"
2677 When standard input is used, the log file, if saved, is \fIperltidy.LOG\fR,
2678 and any errors are written to \fIperltidy.ERR\fR unless the \fB\-se\fR flag is
2679 set.  These are saved in the current working directory.  
2680 .IP "Files overwritten" 4
2681 .IX Item "Files overwritten"
2682 The following file extensions are used by perltidy, and files with these
2683 extensions may be overwritten or deleted: \fI.ERR\fR, \fI.LOG\fR, \fI.TEE\fR,
2684 and/or \fI.tdy\fR, \fI.html\fR, and \fI.bak\fR, depending on the run type and
2685 settings.
2686 .IP "Files extensions limitations" 4
2687 .IX Item "Files extensions limitations"
2688 Perltidy does not operate on files for which the run could produce a file with
2689 a duplicated file extension.  These extensions include \fI.LOG\fR, \fI.ERR\fR,
2690 \&\fI.TEE\fR, and perhaps \fI.tdy\fR and \fI.bak\fR, depending on the run type.  The
2691 purpose of this rule is to prevent generating confusing filenames such as
2692 \&\fIsomefile.tdy.tdy.tdy\fR.
2693 .SH "SEE ALSO"
2694 .IX Header "SEE ALSO"
2695 \&\fIperlstyle\fR\|(1), \fIPerl::Tidy\fR\|(3)
2696 .SH "VERSION"
2697 .IX Header "VERSION"
2698 This man page documents perltidy version 20060614.
2699 .SH "CREDITS"
2700 .IX Header "CREDITS"
2701 Michael Cartmell supplied code for adaptation to \s-1VMS\s0 and helped with
2702 v\-strings.
2703 .PP
2704 Yves Orton supplied code for adaptation to the various versions
2705 of Windows. 
2706 .PP
2707 Axel Rose supplied a patch for MacPerl.
2708 .PP
2709 Hugh S. Myers designed and implemented the initial Perl::Tidy module interface. 
2710 .PP
2711 Many others have supplied key ideas, suggestions, and bug reports;
2712 see the \s-1CHANGES\s0 file.
2713 .SH "AUTHOR"
2714 .IX Header "AUTHOR"
2715 .Vb 3
2716 \&  Steve Hancock
2717 \&  email: perltidy at users.sourceforge.net
2718 \&  http://perltidy.sourceforge.net
2719 .Ve
2720 .SH "COPYRIGHT"
2721 .IX Header "COPYRIGHT"
2722 Copyright (c) 2000\-2006 by Steve Hancock
2723 .SH "LICENSE"
2724 .IX Header "LICENSE"
2725 This package is free software; you can redistribute it and/or modify it
2726 under the terms of the \*(L"\s-1GNU\s0 General Public License\*(R".
2727 .PP
2728 Please refer to the file \*(L"\s-1COPYING\s0\*(R" for details.
2729 .SH "DISCLAIMER"
2730 .IX Header "DISCLAIMER"
2731 This package is distributed in the hope that it will be useful,
2732 but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
2733 \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0.
2734 .PP
2735 See the \*(L"\s-1GNU\s0 General Public License\*(R" for more details.