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