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