+<h2 id="Adding-and-Deleting-Commas">Adding and Deleting Commas</h2>
+
+<dl>
+
+<dt id="drc---delete-repeated-commas"><b>-drc</b>, <b>--delete-repeated-commas</b></dt>
+<dd>
+
+<p>Repeated commas in a list are undesirable and can be removed with this flag. For example, given this list with a repeated comma</p>
+
+<pre><code> ignoreSpec( $file, "file",, \%spec, \%Rspec );</code></pre>
+
+<p>we can remove it with -drc</p>
+
+<pre><code> # perltidy -drc:
+ ignoreSpec( $file, "file", \%spec, \%Rspec );</code></pre>
+
+<p>Since the default is not to add or delete commas, this feature is off by default and must be requested.</p>
+
+</dd>
+<dt id="want-trailing-commas-s-or--wtc-s---add-trailing-commas-or--atc-and---delete-trailing-commas-or--dtc"><b>--want-trailing-commas=s</b> or <b>-wtc=s</b>, <b>--add-trailing-commas</b> or <b>-atc</b>, and <b>--delete-trailing-commas</b> or <b>-dtc</b></dt>
+<dd>
+
+<p>A trailing comma is a comma following the last item of a list. Perl allows trailing commas but they are not required. By default, perltidy does not add or delete trailing commas, but it is possible to manipulate them with the following set of three related parameters:</p>
+
+<pre><code> --want-trailing-commas=s, -wtc=s - defines where trailing commas are wanted
+ --add-trailing-commas, -atc - gives permission to add trailing commas to match the style wanted
+ --delete-trailing-commas, -dtc - gives permission to delete trailing commas which do not match the style wanted</code></pre>
+
+<p>The parameter <b>--want-trailing-commas=s</b>, or <b>-wtc=s</b>, defines a preferred style. The string <b>s</b> indicates which lists should get trailing commas, as follows:</p>
+
+<pre><code> s=0 : no list should have a trailing comma
+ s=1 or * : every list should have a trailing comma
+ s=m a multi-line list should have a trailing commas
+ s=b trailing commas should be 'bare' (comma followed by newline)
+ s=h lists of key=>value pairs, with about one one '=>' and one ',' per line,
+ with a bare trailing comma
+ s=i lists with about one comma per line, with a bare trailing comma
+ s=' ' or -wtc not defined : leave trailing commas unchanged [DEFAULT].</code></pre>
+
+<p>This parameter by itself only indicates the where trailing commas are wanted. Perltidy only adds these trailing commas if the flag <b>--add-trailing-commas</b>, or <b>-atc</b> is set. And perltidy only removes unwanted trailing commas if the flag <b>--delete-trailing-commas</b>, or <b>-dtc</b> is set.</p>
+
+<p>Here are some example parameter combinations and their meanings</p>
+
+<pre><code> -wtc=0 -dtc : delete all trailing commas
+ -wtc=1 -atc : all lists get trailing commas
+ -wtc=m -atc : all multi-line lists get trailing commas, but
+ single line lists remain unchanged.
+ -wtc=m -dtc : multi-line lists remain unchanged, but
+ any trailing commas on single line lists are removed.
+ -wtc=m -atc -dtc : all multi-line lists get trailing commas, and
+ any trailing commas on single line lists are removed.</code></pre>
+
+<p>For example, given the following input without a trailing comma</p>
+
+<pre><code> bless {
+ B => $B,
+ Root => $Root
+ } => $package;</code></pre>
+
+<p>we can add a trailing comma after the variable <code>$Root</code> using</p>
+
+<pre><code> # perltidy -wtc=m -atc
+ bless {
+ B => $B,
+ Root => $Root,
+ } => $package;</code></pre>
+
+<p>This could also be achieved in this case with <b>-wtc=b</b> instead of <b>-wtc=m</b> because the trailing comma here is bare (separated from its closing brace by a newline). And it could also be achieved with <b>-wtc=h</b> because this particular list is a list of key=>value pairs.</p>
+
+<p>The above styles should cover the main of situations of interest, but it is possible to apply a different style to each type of container token by including an opening token ahead of the style character in the above table. For example</p>
+
+<pre><code> -wtc='(m [b'</code></pre>
+
+<p>means that lists within parens should have multi-line trailing commas, and that lists within square brackets have bare trailing commas. Since there is no specification for curly braces in this example, their trailing commas would remain unchanged.</p>
+
+<p>For parentheses, an additional item of information which can be given is an alphanumeric letter which is used to limit the selection further depending on the type of token immediately before the opening paren. The possible letters are currently 'k', 'K', 'f', 'F', 'w', and 'W', with these meanings for matching whatever precedes an opening paren:</p>
+
+<pre><code> 'k' matches if the previous nonblank token is a perl built-in keyword (such as 'if', 'while'),
+ 'K' matches if 'k' does not, meaning that the previous token is not a keyword.
+ 'f' matches if the previous token is a function other than a keyword.
+ 'F' matches if 'f' does not.
+ 'w' matches if either 'k' or 'f' match.
+ 'W' matches if 'w' does not.</code></pre>
+
+<p>These are the same codes used for <b>--line-up-parentheses-inclusion-list</b>. For example,</p>
+
+<pre><code> -wtc = 'w(m'</code></pre>
+
+<p>means that trailing commas are wanted for multi-line parenthesized lists following a function call or keyword.</p>
+
+<p>Here are some points to note regarding adding and deleting trailing commas:</p>
+
+<ul>
+
+<li><p>For the implementation of these parameters, a <b>list</b> is basically taken to be a container of items (parens, square brackets, or braces), which is not a code block, with one or more commas. These parameters only apply to something that fits this definition of a list.</p>
+
+<p>Note that a paren-less list of parameters is not a list by this definition, so these parameters have no effect on a peren-less list.</p>
+
+<p>Another consequence is that if the only comma in a list is deleted, then it cannot later be added back with these parameters because the container no longer fits this definition of a list. For example, given</p>
+
+<pre><code> my ( $self, ) = @_;</code></pre>
+
+<p>and if we remove the comma with</p>
+
+<pre><code> # perltidy -wtc=m -dtc
+ my ( $self ) = @_;</code></pre>
+
+<p>then we cannot use these trailing comma controls to add this comma back.</p>
+
+</li>
+<li><p>By <b>multiline</b> list is meant a list for which the first comma and trailing comma are on different lines.</p>
+
+</li>
+<li><p>A <b>bare</b> trailing comma is a comma which is at the end of a line. That is, the closing container token follows on a different line. So a list with a bare trailing comma is a special case of a multi-line list.</p>
+
+</li>
+<li><p>The decision regarding whether or not a list is multi-line or bare is made based on the <b>input</b> stream. In some cases it may take an iteration or two to reach a final state.</p>
+
+</li>
+<li><p>When using these parameters for the first time it is a good idea to practice on some test scripts and verify that the results are as expected.</p>
+
+</li>
+<li><p>Since the default behavior is not to add or delete commas, these parameters can be useful on a temporary basis for reformatting a script.</p>
+
+</li>
+</ul>
+
+</dd>
+<dt id="dwic---delete-weld-interfering-commas"><b>-dwic</b>, <b>--delete-weld-interfering-commas</b></dt>
+<dd>
+
+<p>If the closing tokens of two nested containers are separated by a comma, then welding requested with <b>--weld-nested-containers</b> cannot occur. Any commas in this situation are optional trailing commas and can be removed with <b>-dwic</b>. For example, a comma in this script prevents welding:</p>
+
+<pre><code> # perltidy -wn
+ skip_symbols(
+ [ qw(
+ Perl_dump_fds
+ Perl_ErrorNo
+ Perl_GetVars
+ PL_sys_intern
+ ) ],
+ );</code></pre>
+
+<p>Using <b>-dwic</b> removes the comma and allows welding:</p>
+
+<pre><code> # perltidy -wn -dwic
+ skip_symbols( [ qw(
+ Perl_dump_fds
+ Perl_ErrorNo
+ Perl_GetVars
+ PL_sys_intern
+ ) ] );</code></pre>
+
+<p>Since the default is not to add or delete commas, this feature is off by default. Here are some points to note about the <b>-dwic</b> parameter</p>
+
+<ul>
+
+<li><p>This operation is not reversible, so please check results of using this parameter carefully.</p>
+
+</li>
+<li><p>Removing this type of isolated trailing comma is necessary for welding to be possible, but not sufficient. So welding will not always occur where these commas are removed.</p>
+
+</li>
+</ul>
+
+</dd>
+</dl>
+