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