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