"Fossies" - the Fresh Open Source Software Archive

Member "Perl-Tidy-20200110/docs/perltidy.html" (9 Jan 2020, 177673 Bytes) of package /linux/misc/Perl-Tidy-20200110.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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