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