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