# Github files
\.travis\.yml
+# Jekyl file
+_config.yml
+
# tidyall files
\.tidyall
^local-docs/
-# this is reserved for html pages
-^docs/
-
^archive/
-# Welcome to Perltidy!
+# Welcome to Perltidy
Perltidy is a tool to indent and reformat perl scripts. It can also
write scripts in html format.
Perltidy is free software released under the GNU General Public
License -- please see the included file "COPYING" for details.
-# PREREQUISITES
+Documentation can be found at the web site [at GitHub](https://perltidy.github.io/perltidy/)
+or [at Sourceforge](perltidy.sourceforge.net)
-`perltidy` should work with most standard Perl installations.
-The following modules are not required, but perltidy may use them if
-detected:
-
- HTML::Entities will be used to encode HTML entities if detected
- Pod::Html will be used to format pod text
-
-The total disk space needed after removing the installation directory will
-about 2 Mb.
-
-# DOWNLOAD
-
-There are two source distribution files:
-
-- A `.tgz` "tarball", with Unix-style <lf> line endings, and
-- A zip file, `.zip`, with Windows-style <cr><lf> line endings.
-
-In addition, the web site has links to debian and RPM packages.
-
-# INSTALLATION
-
-For most standard installations, the standard Makefile.PL method should work:
-
- perl Makefile.PL
- make
- make test
- make install
-
-The INSTALL file has additional installation notes, and tells how
-to use perltidy without doing an installation.
-
-# WHAT NEXT
-
-Please see the CHANGES file for notices of any recent updates.
-
-Please see the BUGS file for a list of all known open bugs.
-
-Documentation can be found in the `docs` directory, and it can also be
-found at http://perltidy.sourceforge.net
-
-Reading the brief tutorial should help you use perltidy effectively.
-
-# FEEDBACK / BUG REPORTS
-
-A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
-
-To report a new bug or problem, use the link on this page .
+A copy of the web site in contained in the docs folder of the distribution.
--- /dev/null
+# Perltidy open BUGS and LIMITATIONS
+
+You can help perltidy evolve into a better program. If you think you
+have hit a bug or weird behavior, or have a suggested improvement,
+please send a note to perltidy at users.sourceforge.net.
+
+This file only lists open bugs. For bugs which have been fixed,
+see the ChangeLog.
+
+## The --extrude and --mangle options can produce code with syntax errors
+
+The --extrude tries to put as many newlines in the formatted code as possible.
+The --mangle tries to remove as many newlines as possible. These options are
+very useful for stress testing perltidy (and Perl) but not so much for normal
+formatting. Occasionally they will produce code which Perl considers to have a
+syntax error. These problems often involve code where Perl is having to guess
+the tokenization based on whitespace. The given/when and switch/case
+statements are also particularly vulnerable to unusual line breaks and
+whitespace. This type of error should not normally occur in practice, but if
+it does it should be easy to fix the problem by rerunning perltidy with more
+normal parameters or by manually changing whitespace or newlines.
+
+## The Pod:Html module has some bugs
+
+For the most part Pod::Html works very well and is very convenient because
+it part of the standard Perl distribution. But for example the following line
+
+ =item B<< <Deck> = Session->new_cflt_deck; >>
+
+which uses double brackets to contain single brackets does not render correctly.
+
+## Two iterations are sometimes needed
+
+Usually the code produced by perltidy on the first pass does not change if it
+is run again, but sometimes a second pass will produce some small additional
+change. This mainly happens if a major style change is made, particularly when
+perltidy is untangling complex ternary statements. Use the iteration parameter
+**-it=2** if it is important that the results be unchanged on subsequent passes,
+but note that this doubles the run time.
+
+## Latest Bug and Wishlist at CPAN:
+
+For the latest list of bugs and feature requests at CPAN see:
+
+https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#Perltidy-Change-Log">Perltidy Change Log</a>
- <ul>
- <li><a href="#pod2018-02-20.01">2018 02 20.01</a></li>
- <li><a href="#pod2018-02-20">2018 02 20</a></li>
- <li><a href="#pod2018-02-19">2018 02 19</a></li>
- <li><a href="#pod2018-01-01">2018 01 01</a></li>
- <li><a href="#pod2017-12-14">2017 12 14</a></li>
- <li><a href="#pod2017-05-21">2017 05 21</a></li>
- <li><a href="#pod2016-03-02">2016 03 02</a></li>
- <li><a href="#pod2016-03-01">2016 03 01</a></li>
- <li><a href="#pod2015-08-15">2015 08 15</a></li>
- <li><a href="#pod2014-07-11">2014 07 11</a></li>
- <li><a href="#pod2014-03-28">2014 03 28</a></li>
- <li><a href="#pod2013-09-22">2013 09 22</a></li>
- <li><a href="#pod2013-08-06">2013 08 06</a></li>
- <li><a href="#pod2013-08-05">2013 08 05</a></li>
- <li><a href="#pod2013-07-17">2013 07 17</a></li>
- <li><a href="#pod2012-12-07">2012 12 07</a></li>
- <li><a href="#pod2012-07-14">2012 07 14</a></li>
- <li><a href="#pod2012-07-01">2012 07 01</a></li>
- <li><a href="#pod2012-06-19">2012 06 19</a></li>
- <li><a href="#pod2010-12-17">2010 12 17</a></li>
- <li><a href="#pod2009-06-16">2009 06 16</a></li>
- <li><a href="#pod2007-12-05">2007 12 05</a></li>
- <li><a href="#pod2007-08-01">2007 08 01</a></li>
- <li><a href="#pod2007-05-08">2007 05 08</a></li>
- <li><a href="#pod2007-05-04">2007 05 04</a></li>
- <li><a href="#pod2007-04-24">2007 04 24</a></li>
- <li><a href="#pod2006-07-19">2006 07 19</a></li>
- <li><a href="#pod2006-06-14">2006 06 14</a></li>
- <li><a href="#pod2003-10-21">2003 10 21</a></li>
- <li><a href="#pod2003-07-26">2003 07 26</a></li>
- <li><a href="#pod2002-11-30">2002 11 30</a></li>
- <li><a href="#pod2002-11-06">2002 11 06</a></li>
- <li><a href="#pod2002-09-22">2002 09 22</a></li>
- <li><a href="#pod2002-08-26">2002 08 26</a></li>
- <li><a href="#pod2002-04-25">2002 04 25</a></li>
- <li><a href="#pod2002-04-16">2002 04 16</a></li>
- <li><a href="#pod2002-02-25">2002 02 25</a></li>
- <li><a href="#pod2001-12-31">2001 12 31</a></li>
- <li><a href="#pod2001-11-28">2001 11 28</a></li>
- <li><a href="#pod2001-10-20">2001 10 20</a></li>
- <li><a href="#pod2001-10-16">2001 10 16</a></li>
- <li><a href="#pod2001-09-03">2001 09 03</a></li>
- <li><a href="#pod2001-07-31">2001 07 31</a></li>
- <li><a href="#pod2001-07-23">2001 07 23</a></li>
- <li><a href="#pod2001-07-02">2001 07 02</a></li>
- <li><a href="#pod2001-07-01">2001 07 01</a></li>
- <li><a href="#pod2001-06-17">2001 06 17</a></li>
- <li><a href="#pod2001-06-08">2001 06 08</a></li>
- <li><a href="#pod2001-04-06">2001 04 06</a></li>
- <li><a href="#pod2001-03-28">2001 03 28:</a></li>
- <li><a href="#pod2001-03-23">2001 03 23:</a></li>
- <li><a href="#pod2001-03-04">2001 03 04:</a></li>
- <li><a href="#pod2001-03-03">2001 03 03:</a></li>
- </ul>
- </li>
-</ul>
-
-<h1 id="Perltidy-Change-Log">Perltidy Change Log</h1>
-
-<h2 id="pod2018-02-20.01">2018 02 20.01</h2>
-
-<pre><code> - The packaging for this version has changed. The Tidy.pm file has
- been split into a smaller Tidy.pm file plus supporting modules in the path
- Perl/Tidy/*.
-
- - Fixed RT #126965, in which a ternary operator was misparsed if immediately
- following a function call without arguments, such as:
- my $restrict_customer = shift ? 1 : 0;
-
- - Fixed RT #125012: bug in -mangle --delete-all-comments
- A needed blank space bareword tokens was being removed when comments were
- deleted
-
- - Fixed RT #81852: Stacked containers and quoting operators. Quoted words
- (qw) delimited by container tokens ('{', '[', '(', '<') are now included in
- the --weld-nested (-wn) flag:
-
- # perltidy -wn
- use_all_ok( qw{
- PPI
- PPI::Tokenizer
- PPI::Lexer
- PPI::Dumper
- PPI::Find
- PPI::Normal
- PPI::Util
- PPI::Cache
- } );
-
- - The cuddled-else (-ce) coding was merged with the new cuddled-block (-cb)
- coding. The change is backward compatible and simplifies input.
- The --cuddled-block-option=n (-cbo=n) flag now applies to both -ce and -cb
- formatting. In fact the -cb flag is just an alias for -ce now.
-
- - Fixed RT #124594, license text desc. changed from 'GPL-2.0+' to 'gpl_2'
-
- - RT #106493; source code repository is https://github.com/perltidy/perltidy
-
- - Numerous installation test snippets have been added.
-
- - Fixed bug in which a warning about a possible code bug was issued in a
- script with brace errors.
-
- - added option --notimestamp or -nts to eliminate any time stamps in output
- files. This is used to prevent differences in test scripts from causing
- failure at installation. For example, the -cscw option will put a date
- stamp on certain closing side comments. We need to avoid this in order
- to test this feature in an installation test.
-
- - Fixed bug with the entab option, -et=8, in which the leading space of
- some lines was was not entabbed. This happened in code which was adjusted
- for vertical alignment and in hanging side comments. Thanks to Glenn.
-
- - Vertical alignment has been improved in several ways. Thanks especially to
- Glenn for sending helpful snippets.
-
- - In many cases, two lines which were previously left unaligned are now
- aligned.
-
- OLD:
- $expect = "1$expect" if $expect =~ /^e/i;
- $p = "1$p" if defined $p and $p =~ /^e/i;
-
- NEW:
- $expect = "1$expect" if $expect =~ /^e/i;
- $p = "1$p" if defined $p and $p =~ /^e/i;
-
- - Alignment of the =~ operators has been reactivated.
-
- OLD:
- $service_profile =~ s/^\s+|\s+$//g;
- $host_profile =~ s/^\s+|\s+$//g;
-
- NEW:
- $service_profile =~ s/^\s+|\s+$//g;
- $host_profile =~ s/^\s+|\s+$//g;
-
- - Alignment of the // operator has been reactivated.
-
- OLD:
- is( pop // 7, 7, 'pop // ... works' );
- is( pop() // 7, 0, 'pop() // ... works' );
- is( pop @ARGV // 7, 3, 'pop @array // ... works' );
-
- NEW:
- is( pop // 7, 7, 'pop // ... works' );
- is( pop() // 7, 0, 'pop() // ... works' );
- is( pop @ARGV // 7, 3, 'pop @array // ... works' );</code></pre>
-
-<h2 id="pod2018-02-20">2018 02 20</h2>
-
-<pre><code> - RT #124469, #124494, perltidy often making empty files. The previous had
- an index error causing it to fail, particularly in version 5.18 of Perl.
-
- Please avoid version 20180219.</code></pre>
-
-<h2 id="pod2018-02-19">2018 02 19</h2>
-
-<pre><code> - RT #79947, cuddled-else generalization. A new flag -cb provides
- 'cuddled-else' type formatting for an arbitrary type of block chain. The
- default is try-catch-finally, but this can be modified with the
- parameter -cbl.
-
- - Fixed RT #124298: add space after ! operator without breaking !! secret
- operator
-
- - RT #123749: numerous minor improvements to the -wn flag were made.
-
- - Fixed a problem with convergence tests in which iterations were stopping
- prematurely.
-
- - Here doc targets for <<~ type here-docs may now have leading whitespace.
-
- - Fixed RT #124354. The '-indent-only' flag was not working correctly in the
- previous release. A bug in version 20180101 caused extra blank lines
- to be output.
-
- - Issue RT #124114. Some improvements were made in vertical alignment
- involving 'fat commas'.</code></pre>
-
-<h2 id="pod2018-01-01">2018 01 01</h2>
-
-<pre><code> - Added new flag -wn (--weld-nested-containers) which addresses these issues:
- RT #123749: Problem with promises;
- RT #119970: opening token stacking strange behavior;
- RT #81853: Can't stack block braces
-
- This option causes closely nested pairs of opening and closing containers
- to be "welded" together and essentially be formatted as a single unit,
- with just one level of indentation.
-
- Since this is a new flag it is set to be "off" by default but it has given
- excellent results in testing.
-
- EXAMPLE 1, multiple blocks, default formatting:
- do {
- {
- next if $x == $y; # do something here
- }
- } until $x++ > $z;
-
- perltidy -wn
- do { {
- next if $x == $y;
- } } until $x++ > $z;
-
- EXAMPLE 2, three levels of wrapped function calls, default formatting:
- p(
- em(
- conjug(
- translate( param('verb') ), param('tense'),
- param('person')
- )
- )
- );
-
- # perltidy -wn
- p( em( conjug(
- translate( param('verb') ),
- param('tense'), param('person')
- ) ) );
-
- # EXAMPLE 3, chained method calls, default formatting:
- get('http://mojolicious.org')->then(
- sub {
- my $mojo = shift;
- say $mojo->res->code;
- return get('http://metacpan.org');
- }
- )->then(
- sub {
- my $cpan = shift;
- say $cpan->res->code;
- }
- )->catch(
- sub {
- my $err = shift;
- warn "Something went wrong: $err";
- }
- )->wait;
-
- # perltidy -wn
- get('http://mojolicious.org')->then( sub {
- my $mojo = shift;
- say $mojo->res->code;
- return get('http://metacpan.org');
- } )->then( sub {
- my $cpan = shift;
- say $cpan->res->code;
- } )->catch( sub {
- my $err = shift;
- warn "Something went wrong: $err";
- } )->wait;
-
-
- - Fixed RT #114359: Missparsing of "print $x ** 0.5;
-
- - Deactivated the --check-syntax flag for better security. It will be
- ignored if set.
-
- - Corrected minimum perl version from 5.004 to 5.008 based on perlver
- report. The change is required for coding involving wide characters.
-
- - For certain severe errors, the source file will be copied directly to the
- output without formatting. These include ending in a quote, ending in a
- here doc, and encountering an unidentified character.</code></pre>
-
-<h2 id="pod2017-12-14">2017 12 14</h2>
-
-<pre><code> - RT #123749, partial fix. "Continuation indentation" is removed from lines
- with leading closing parens which are part of a call chain.
- For example, the call to pack() is is now outdented to the starting
- indentation in the following experession:
-
- # OLD
- $mw->Button(
- -text => "New Document",
- -command => \&new_document
- )->pack(
- -side => 'bottom',
- -anchor => 'e'
- );
-
- # NEW
- $mw->Button(
- -text => "New Document",
- -command => \&new_document
- )->pack(
- -side => 'bottom',
- -anchor => 'e'
- );
-
- This modification improves readability of complex expressions, especially
- when the user uses the same value for continuation indentation (-ci=n) and
- normal indentation (-i=n). Perltidy was already programmed to
- do this but a minor bug was preventing it.
-
- - RT #123774, added flag to control space between a backslash and a single or
- double quote, requested by Robert Rothenberg. The issue is that lines like
-
- $str1=\"string1";
- $str2=\'string2';
-
- confuse syntax highlighters unless a space is left between the backslash and
- the quote.
-
- The new flag to control this is -sbq=n (--space-backslash-quote=n),
- where n=0 means no space, n=1 means follow existing code, n=2 means always
- space. The default is n=1, meaning that a space will be retained if there
- is one in the source code.
-
- - Fixed RT #123492, support added for indented here doc operator <<~ added
- in v5.26. Thanks to Chris Weyl for the report.
-
- - Fixed docs; --closing-side-comment-list-string should have been just
- --closing-side-comment-list. Thanks to F.Li.
-
- - Added patch RT #122030] Perl::Tidy sometimes does not call binmode.
- Thanks to Irilis Aelae.
-
- - Fixed RT #121959, PERLTIDY doesn't honor the 'three dot' notation for
- locating a config file using environment variables. Thanks to John
- Wittkowski.
-
- - Minor improvements to formatting, in which some additional vertical
- aligmnemt is done. Thanks to Keith Neargarder.
-
- - RT #119588. Vertical alignment is no longer done for // operator.</code></pre>
-
-<h2 id="pod2017-05-21">2017 05 21</h2>
-
-<pre><code> - Fixed debian #862667: failure to check for perltidy.ERR deletion can lead
- to overwriting abritrary files by symlink attack. Perltidy was continuing
- to write files after an unlink failure. Thanks to Don Armstrong
- for a patch.
-
- - Fixed RT #116344, perltidy fails on certain anonymous hash references:
- in the following code snippet the '?' was misparsed as a pattern
- delimiter rather than a ternary operator.
- return ref {} ? 1 : 0;
-
- - Fixed RT #113792: misparsing of a fat comma (=>) right after
- the __END__ or __DATA__ tokens. These keywords were getting
- incorrectly quoted by the following => operator.
-
- - Fixed RT #118558. Custom Getopt::Long configuration breaks parsing
- of perltidyrc. Perltidy was resetting the users configuration too soon.
-
- - Fixed RT #119140, failure to parse double diamond operator. Code to
- handle this new operator has been added.
-
- - Fixed RT #120968. Fixed problem where -enc=utf8 didn't work
- with --backup-and-modify-in-place. Thanks to Heinz Knutzen for this patch.
-
- - Fixed minor formatting issue where one-line blocks for subs with signatures
- were unnecesarily broken
-
- - RT #32905, patch to fix utf-8 error when output was STDOUT.
-
- - RT #79947, improved spacing of try/catch/finally blocks. Thanks to qsimpleq
- for a patch.
-
- - Fixed #114909, Anonymous subs with signatures and prototypes misparsed as
- broken ternaries, in which a statement such as this was not being parsed
- correctly:
- return sub ( $fh, $out ) : prototype(*$) { ... }
-
- - Implemented RT #113689, option to introduces spaces after an opening block
- brace and before a closing block brace. Four new optional controls are
- added. The first two define the minimum number of blank lines to be
- inserted
-
- -blao=i or --blank-lines-after-opening-block=i
- -blbc=i or --blank-lines-before-closing-block=i
-
- where i is an integer, the number of lines (the default is 0).
-
- The second two define the types of blocks to which the first two apply
-
- -blaol=s or --blank-lines-after-opening-block-list=s
- -blbcl=s or --blank-lines-before-closing-block-list=s
-
- where s is a string of possible block keywords (default is just 'sub',
- meaning a named subroutine).
-
- For more information please see the documentation.
-
- - The method for specifying block types for certain input parameters has
- been generalized to distinguish between normal named subroutines and
- anonymous subs. The keyword for normal subroutines remains 'sub', and
- the new keyword for anonymous subs is 'asub'.
-
- - Minor documentation changes. The BUGS sections now have a link
- to CPAN where most open bugs and issues can be reviewed and bug reports
- can be submitted. The information in the AUTHOR and CREDITS sections of
- the man pages have been removed from the man pages to streamline the
- documentation. This information is still in the source code.</code></pre>
-
-<h2 id="pod2016-03-02">2016 03 02</h2>
-
-<pre><code> - RT #112534. Corrected a minor problem in which an unwanted newline
- was placed before the closing brace of an anonymous sub with
- a signature, if it was in a list. Thanks to Dmytro Zagashev.
-
- - Corrected a minor problem in which occasional extra indentation was
- given to the closing brace of an anonymous sub in a list when the -lp
- parameter was set.</code></pre>
-
-<h2 id="pod2016-03-01">2016 03 01</h2>
-
-<pre><code> - RT #104427. Added support for signatures.
-
- - RT #111512. Changed global warning flag $^W = 1 to use warnings;
- Thanks to Dmytro Zagashev.
-
- - RT #110297, added support for new regexp modifier /n
- Thanks to Dmytro Zagashev.
-
- - RT #111519. The -io (--indent-only) and -dac (--delete-all-comments)
- can now both be used in one pass. Thanks to Dmitry Veltishev.
-
- - Patch to avoid error message with 'catch' used by TryCatch, as in
- catch($err){
- # do something
- }
- Thanks to Nick Tonkin.
-
- - RT #32905, UTF-8 coding is now more robust. Thanks to qsimpleq
- and Dmytro for patches.
-
- - RT #106885. Added string bitwise operators ^. &. |. ~. ^.= &.= |.=
-
- - Fixed RT #107832 and #106492, lack of vertical alignment of two lines
- when -boc flag (break at old commas) is set. This bug was
- inadvertantly introduced in previous bug fix RT #98902.
-
- - Some common extensions to Perl syntax are handled better.
- In particular, the following snippet is now foratted cleanly:
-
- method deposit( Num $amount) {
- $self->balance( $self->balance + $amount );
- }
-
- A new flag -xs (--extended-syntax) was added to enable this, and the default
- is to use -xs.
-
- In previous versions, and now only when -nxs is set, this snippet of code
- generates the following error message:
-
- "syntax error at ') {', didn't see one of: case elsif for foreach given if switch unless until when while"</code></pre>
-
-<h2 id="pod2015-08-15">2015 08 15</h2>
-
-<pre><code> - Fixed RT# 105484, Invalid warning about 'else' in 'switch' statement. The
- warning happened if a 'case' statement did not use parens.
-
- - Fixed RT# 101547, misparse of // caused error message. Also..
-
- - Fixed RT# 102371, misparse of // caused unwated space in //=
-
- - Fixed RT# 100871, "silent failure of HTML Output on Windows".
- Changed calls to tempfile() from:
- my ( $fh_tmp, $tmpfile ) = tempfile();
- to have the full path name:
- my ( $fh_tmp, $tmpfile ) = File::Temp::tempfile()
- because of problems in the Windows version reported by Dean Pearce.
-
- - Fixed RT# 99514, calling the perltidy module multiple times with
- a .perltidyrc file containing the parameter --output-line-ending
- caused a crash. This was a glitch in the memoization logic.
-
- - Fixed RT#99961, multiple lines inside a cast block caused unwanted
- continuation indentation.
-
- - RT# 32905, broken handling of UTF-8 strings.
- A new flag -utf8 causes perltidy assume UTF-8 encoding for input and
- output of an io stream. Thanks to Sebastian Podjasek for a patch.
- This feature may not work correctly in older versions of Perl.
- It worked in a linux version 5.10.1 but not in a Windows version 5.8.3 (but
- otherwise perltidy ran correctly).
-
- - Warning files now report perltidy VERSION. Suggested by John Karr.
-
- - Fixed long flag --nostack-closing-tokens (-nsct has always worked though).
- This was due to a typo. This also fixed --nostack-opening-tokens to
- behave correctly. Thanks to Rob Dixon.</code></pre>
-
-<h2 id="pod2014-07-11">2014 07 11</h2>
-
-<pre><code> - Fixed RT #94902: abbreviation parsing in .perltidyrc files was not
- working for multi-line abbreviations. Thanks to Eric Fung for
- supplying a patch.
-
- - Fixed RT #95708, misparsing of a hash when the first key was a perl
- keyword, causing a semicolon to be incorrectly added.
-
- - Fixed RT #94338 for-loop in a parenthesized block-map. A code block within
- parentheses of a map, sort, or grep function was being mistokenized. In
- rare cases this could produce in an incorrect error message. The fix will
- produce some minor formatting changes. Thanks to Daniel Trizen
- discovering and documenting this.
-
- - Fixed RT #94354, excess indentation for stacked tokens. Thanks to
- Colin Williams for supplying a patch.
-
- - Added support for experimental postfix dereferencing notation introduced in
- perl 5.20. RT #96021.
-
- - Updated documentation to clarify the behavior of the -io flag
- in response to RT #95709. You can add -noll or -l=0 to prevent
- long comments from being outdented when -io is used.
-
- - Added a check to prevent a problem reported in RT #81866, where large
- scripts which had been compressed to a single line could not be formatted
- because of a check for VERSION for MakeMaker. The workaround was to
- use -nvpl, but this shouldn't be necessary now.
-
- - Fixed RT #96101; Closing brace of anonymous sub in a list was being
- indented. For example, the closing brace of the anonymous sub below
- will now be lined up with the word 'callback'. This problem
- occured if there was no comma after the closing brace of the anonymous sub.
- This update may cause minor changes to formatting of code with lists
- of anonymous subs, especially TK code.
-
- # OLD
- my @menu_items = (
-
- #...
- {
- path => '/_Operate/Transcode and split',
- callback => sub {
- return 1 if not $self->project_opened;
- $self->comp('project')->transcode( split => 1 );
- }
- }
- );
-
- # NEW
- my @menu_items = (
-
- #...
- {
- path => '/_Operate/Transcode and split',
- callback => sub {
- return 1 if not $self->project_opened;
- $self->comp('project')->transcode( split => 1 );
- }
- }
- );</code></pre>
-
-<h2 id="pod2014-03-28">2014 03 28</h2>
-
-<pre><code> - Fixed RT #94190 and debian Bug #742004: perltidy.LOG file left behind.
- Thanks to George Hartzell for debugging this. The problem was
- caused by the memoization speedup patch in version 20121207. An
- unwanted flag was being set which caused a LOG to be written if
- perltidy was called multiple times.
-
- - New default behavior for LOG files: If the source is from an array or
- string (through a call to the perltidy module) then a LOG output is only
- possible if a logfile stream is specified. This is to prevent
- unexpected perltidy.LOG files.
-
- - Fixed debian Bug #740670, insecure temporary file usage. File::Temp is now
- used to get a temporary file. Thanks to Don Anderson for a patch.
-
- - Any -b (--backup-and-modify-in-place) flag is silently ignored when a
- source stream, destination stream, or standard output is used.
- This is because the -b flag may have been in a .perltidyrc file and
- warnings break Test::NoWarnings. Thanks to Marijn Brand. </code></pre>
-
-<h2 id="pod2013-09-22">2013 09 22</h2>
-
-<pre><code> - Fixed RT #88020. --converge was not working with wide characters.
-
- - Fixed RT #78156. package NAMESPACE VERSION syntax not accepted.
-
- - First attempt to fix RT #88588. INDEX END tag change in pod2html breaks
- perltidy -html. I put in a patch which should work but I don't yet have
- a way of testing it.</code></pre>
-
-<h2 id="pod2013-08-06">2013 08 06</h2>
-
-<pre><code> - Fixed RT #87107, spelling</code></pre>
-
-<h2 id="pod2013-08-05">2013 08 05</h2>
-
-<pre><code> - Fixed RT #87502, incorrect of parsing of smartmatch before hash brace
-
- - Added feature request RT #87330, trim whitespace after POD.
- The flag -trp (--trim-pod) will trim trailing whitespace from lines of POD</code></pre>
-
-<h2 id="pod2013-07-17">2013 07 17</h2>
-
-<pre><code> - Fixed RT #86929, #86930, missing lhs of assignment.
-
- - Fixed RT #84922, moved pod from Tidy.pm into Tidy.pod</code></pre>
-
-<h2 id="pod2012-12-07">2012 12 07</h2>
-
-<pre><code> - The flag -cab=n or --comma-arrow-breakpoints=n has been generalized
- to give better control over breaking open short containers. The
- possible values are now:
-
- n=0 break at all commas after =>
- n=1 stable: break at all commas after => if container is open,
- EXCEPT FOR one-line containers
- n=2 break at all commas after =>, BUT try to form the maximum
- maximum one-line container lengths
- n=3 do not treat commas after => specially at all
- n=4 break everything: like n=0 but also break a short container with
- a => not followed by a comma
- n=5 stable: like n=1 but ALSO break at open one-line containers (default)
-
- New values n=4 and n=5 have been added to allow short blocks to be
- broken open. The new default is n=5, stable. It should more closely
- follow the breaks in the input file, and previously formatted code
- should remain unchanged. If this causes problems use -cab=1 to recover
- the former behavior. Thanks to Tony Maszeroski for the suggestion.
-
- To illustrate the need for the new options, if perltidy is given
- the following code, then the old default (-cab=1) was to close up
- the 'index' container even if it was open in the source. The new
- default (-cab=5) will keep it open if it was open in the source.
-
- our $fancypkg = {
- 'ALL' => {
- 'index' => {
- 'key' => 'value',
- },
- 'alpine' => {
- 'one' => '+',
- 'two' => '+',
- 'three' => '+',
- },
- }
- };
-
- - New debug flag --memoize (-mem). This version contains a
- patch supplied by Jonathan Swartz which can significantly speed up
- repeated calls to Perl::Tidy::perltidy in a single process by caching
- the result of parsing the formatting parameters. A factor of up to 10
- speedup was achieved for masontidy (https://metacpan.org/module/masontidy).
- The memoization patch is on by default but can be deactivated for
- testing with -nmem (or --no-memoize).
-
- - New flag -tso (--tight-secret-operators) causes certain perl operator
- sequences (secret operators) to be formatted "tightly" (without spaces).
- The most common of these are 0 + and + 0 which become 0+ and +0. The
- operators currently modified by this flag are:
- =( )= 0+ +0 ()x!! ~~<> ,=>
- Suggested by by Philippe Bruhat. See https://metacpan.org/module/perlsecret
- This flag is off by default.
-
- - New flag -vmll (--variable-maximum-line-length) makes the maximum
- line length increase with the nesting depth of a line of code.
- Basically, it causes the length of leading whitespace to be ignored when
- setting line breaks, so the formatting of a block of code is independent
- of its nesting depth. Try this option if you have deeply nested
- code or data structures, perhaps in conjunction with the -wc flag
- described next. The default is not todo this.
-
- - New flag -wc=n (--whitespace-cycle=n) also addresses problems with
- very deeply nested code and data structures. When this parameter is
- used and the nesting depth exceeds the value n, the leading whitespace
- will be reduced and start at 1 again. The result is that deeply
- nested blocks of code will shift back to the left. This occurs cyclically
- to any nesting depth. This flag may be used either with or without -vmll.
- The default is not to use this (-wc=0).
-
- - Fixed RT #78764, error parsing smartmatch operator followed by anonymous
- hash or array and then a ternary operator; two examples:
-
- qr/3/ ~~ ['1234'] ? 1 : 0;
- map { $_ ~~ [ '0', '1' ] ? 'x' : 'o' } @a;
-
- - Fixed problem with specifying spaces around arrows using -wls='->'
- and -wrs='->'. Thanks to Alain Valleton for documenting this problem.
-
- - Implemented RT #53183, wishlist, lines of code with the same indentation
- level which are contained with multiple stacked opening and closing tokens
- (requested with flags -sot -sct) now have reduced indentation.
-
- # Default
- $sender->MailMsg(
- {
- to => $addr,
- subject => $subject,
- msg => $body
- }
- );
-
- # OLD: perltidy -sot -sct
- $sender->MailMsg( {
- to => $addr,
- subject => $subject,
- msg => $body
- } );
-
- # NEW: perltidy -sot -sct
- $sender->MailMsg( {
- to => $addr,
- subject => $subject,
- msg => $body
- } );
-
- - New flag -act=n (--all-containers-tightness=n) is an abbreviation for
- -pt=n -sbt=n -bt=n -bbt=n, where n=0,1, or 2. It simplifies input when all
- containers have the same tightness. Using the same example:
-
- # NEW: perltidy -sot -sct -act=2
- $sender->MailMsg({
- to => $addr,
- subject => $subject,
- msg => $body
- });
-
- - New flag -sac (--stack-all-containers) is an abbreviation for -sot -sct
- This is part of wishlist item RT #53183. Using the same example again:
-
- # NEW: perltidy -sac -act=2
- $sender->MailMsg({
- to => $addr,
- subject => $subject,
- msg => $body
- });
-
- - new flag -scbb (--stack-closing-block-brace) causes isolated closing
- block braces to stack as in the following example. (Wishlist item RT#73788)
-
- DEFAULT:
- for $w1 (@w1) {
- for $w2 (@w2) {
- for $w3 (@w3) {
- for $w4 (@w4) {
- push( @lines, "$w1 $w2 $w3 $w4\n" );
- }
- }
- }
- }
-
- perltidy -scbb:
- for $w1 (@w1) {
- for $w2 (@w2) {
- for $w3 (@w3) {
- for $w4 (@w4) {
- push( @lines, "$w1 $w2 $w3 $w4\n" );
- } } } }
-
- There is, at present, no flag to place these closing braces at the end
- of the previous line. It seems difficult to develop good rules for
- doing this for a wide variety of code and data structures.
-
- - Parameters defining block types may use a wildcard '*' to indicate
- all block types. Previously it was not possible to include bare blocks.
-
- - A flag -sobb (--stack-opening-block-brace) has been introduced as an
- alias for -bbvt=2 -bbvtl='*'. So for example the following test code:
-
- {{{{{{{ $testing }}}}}}}
-
- cannot be formatted as above but can at least be kept vertically compact
- using perltidy -sobb -scbb
-
- { { { { { { { $testing
- } } } } } } }
-
- Or even, perltidy -sobb -scbb -i=1 -bbt=2
- {{{{{{{$testing
- }}}}}}}
-
-
- - Error message improved for conflicts due to -pbp; thanks to Djun Kim.
-
- - Fixed RT #80645, error parsing special array name '@$' when used as
- @{$} or $#{$}
-
- - Eliminated the -chk debug flag which was included in version 20010406 to
- do a one-time check for a bug with multi-line quotes. It has not been
- needed since then.
-
- - Numerous other minor formatting improvements.</code></pre>
-
-<h2 id="pod2012-07-14">2012 07 14</h2>
-
-<pre><code> - Added flag -iscl (--ignore-side-comment-lengths) which causes perltidy
- to ignore the length of side comments when setting line breaks,
- RT #71848. The default is to include the length of side comments when
- breaking lines to stay within the length prescribed by the -l=n
- maximum line length parameter. For example,
-
- Default behavior on a single line with long side comment:
- $vmsfile =~ s/;[\d\-]*$//
- ; # Clip off version number; we can use a newer version as well
-
- perltidy -iscl leaves the line intact:
-
- $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well
-
- - Fixed RT #78182, side effects with STDERR. Error handling has been
- revised and the documentation has been updated. STDERR can now be
- redirected to a string reference, and perltidy now returns an
- error flag instead of calling die when input errors are detected.
- If the error flag is set then no tidied output was produced.
- See man Perl::Tidy for an example.
-
- - Fixed RT #78156, erroneous warning message for package VERSION syntax.
-
- - Added abbreviations -conv (--converge) to simplify iteration control.
- -conv is equivalent to -it=4 and will insure that the tidied code is
- converged to its final state with the minimum number of iterations.
-
- - Minor formatting modifications have been made to insure convergence.
-
- - Simplified and hopefully improved the method for guessing the starting
- indentation level of entabbed code. Added flag -dt=n (--default_tabsize=n)
- which might be helpful if the guessing method does not work well for
- some editors.
-
- - Added support for stacked labels, upper case X/B in hex and binary, and
- CORE:: namespace.
-
- - Eliminated warning messages for using keyword names as constants.</code></pre>
-
-<h2 id="pod2012-07-01">2012 07 01</h2>
-
-<pre><code> - Corrected problem introduced by using a chomp on scalar references, RT #77978
-
- - Added support for Perl 5.14 package block syntax, RT #78114.
-
- - A convergence test is made if three or more iterations are requested with
- the -it=n parameter to avoid wasting computer time. Several hundred Mb of
- code gleaned from the internet were searched with the results that:
- - It is unusual for two iterations to be required unless a major
- style change is being made.
- - Only one case has been found where three iterations were required.
- - No cases requiring four iterations have been found with this version.
- For the previous version several cases where found the results could
- oscillate between two semi-stable states. This version corrects this.
-
- So if it is important that the code be converged it is okay to set -it=4
- with this version and it will probably stop after the second iteration.
-
- - Improved ability to identify and retain good line break points in the
- input stream, such as at commas and equals. You can always tell
- perltidy to ignore old breakpoints with -iob.
-
- - Fixed glitch in which a terminal closing hash brace followed by semicolon
- was not outdented back to the leading line depth like other closing
- tokens. Thanks to Keith Neargarder for noting this.
-
- OLD:
- my ( $pre, $post ) = @{
- {
- "pp_anonlist" => [ "[", "]" ],
- "pp_anonhash" => [ "{", "}" ]
- }->{ $kid->ppaddr }
- }; # terminal brace
-
- NEW:
- my ( $pre, $post ) = @{
- {
- "pp_anonlist" => [ "[", "]" ],
- "pp_anonhash" => [ "{", "}" ]
- }->{ $kid->ppaddr }
- }; # terminal brace
-
- - Removed extra indentation given to trailing 'if' and 'unless' clauses
- without parentheses because this occasionally produced undesirable
- results. This only applies where parens are not used after the if or
- unless.
-
- OLD:
- return undef
- unless my ( $who, $actions ) =
- $clause =~ /^($who_re)((?:$action_re)+)$/o;
-
- NEW:
- return undef
- unless my ( $who, $actions ) =
- $clause =~ /^($who_re)((?:$action_re)+)$/o; </code></pre>
-
-<h2 id="pod2012-06-19">2012 06 19</h2>
-
-<pre><code> - Updated perltidy to handle all quote modifiers defined for perl 5 version 16.
-
- - Side comment text in perltidyrc configuration files must now begin with
- at least one space before the #. Thus:
-
- OK:
- -l=78 # Max line width is 78 cols
- BAD:
- -l=78# Max line width is 78 cols
-
- This is probably true of almost all existing perltidyrc files,
- but if you get an error message about bad parameters
- involving a '#' the first time you run this version, please check the side
- comments in your perltidyrc file, and add a space before the # if necessary.
- You can quickly see the contents your perltidyrc file, if any, with the
- command:
-
- perltidy -dpro
-
- The reason for this change is that some parameters naturally involve
- the # symbol, and this can get interpreted as a side comment unless the
- parameter is quoted. For example, to define -sphb=# it used to be necessary
- to write
- -sbcp='#'
- to keep the # from becoming part of a comment. This was causing
- trouble for new users. Now it can also be written without quotes:
- -sbcp=#
-
- - Fixed bug in processing some .perltidyrc files containing parameters with
- an opening brace character, '{'. For example the following was
- incorrectly processed:
- --static-block-comment-prefix="^#{2,}[^\s#]"
- Thanks to pdagosto.
-
- - Added flag -boa (--break-at-old-attribute-breakpoints) which retains
- any existing line breaks at attribute separation ':'. This is now the
- default, use -nboa to deactivate. Thanks to Daphne Phister for the patch.
- For example, given the following code, the line breaks at the ':'s will be
- retained:
-
- my @field
- : field
- : Default(1)
- : Get('Name' => 'foo') : Set('Name');
-
- whereas the previous version would have output a single line. If
- the attributes are on a single line then they will remain on a single line.
-
- - Added new flags --blank-lines-before-subs=n (-blbs=n) and
- --blank-lines-before-packages=n (-blbp=n) to put n blank lines before
- subs and packages. The old flag -bbs is now equivalent to -blbs=1 -blbp=1.
- and -nbbs is equivalent to -blbs=0 -blbp=0. Requested by M. Schwern and
- several others.
-
- - Added feature -nsak='*' meaning no space between any keyword and opening
- paren. This avoids listing entering a long list of keywords. Requested
- by M. Schwern.
-
- - Added option to delete a backup of original file with in-place-modify (-b)
- if there were no errors. This can be requested with the flag -bext='/'.
- See documentation for details. Requested by M. Schwern and others.
-
- - Fixed bug where the module postfilter parameter was not applied when -b
- flag was used. This was discovered during testing.
-
- - Fixed in-place-modify (-b) to work with symbolic links to source files.
- Thanks to Ted Johnson.
-
- - Fixed bug where the Perl::Tidy module did not allow -b to be used
- in some cases.
-
- - No extra blank line is added before a comment which follows
- a short line ending in an opening token, for example like this:
- OLD:
- if (
-
- # unless we follow a blank or comment line
- $last_line_leading_type !~ /^[#b]$/
- ...
-
- NEW:
- if (
- # unless we follow a blank or comment line
- $last_line_leading_type !~ /^[#b]$/
- ...
-
- The blank is not needed for readability in these cases because there
- already is already space above the comment. If a blank already
- exists there it will not be removed, so this change should not
- change code which has previously been formatted with perltidy.
- Thanks to R.W.Stauner.
-
- - Likewise, no extra blank line is added above a comment consisting of a
- single #, since nothing is gained in readability.
-
- - Fixed error in which a blank line was removed after a #>>> directive.
- Thanks to Ricky Morse.
-
- - Unnecessary semicolons after given/when/default blocks are now removed.
-
- - Fixed bug where an unwanted blank line could be added before
- pod text in __DATA__ or __END__ section. Thanks to jidani.
-
- - Changed exit flags from 1 to 0 to indicate success for -help, -version,
- and all -dump commands. Also added -? as another way to dump the help.
- Requested by Keith Neargarder.
-
- - Fixed bug where .ERR and .LOG files were not written except for -it=2 or more
-
- - Fixed bug where trailing blank lines at the end of a file were dropped when
- -it>1.
-
- - Fixed bug where a line occasionally ended with an extra space. This reduces
- rhe number of instances where a second iteration gives a result different
- from the first.
-
- - Updated documentation to note that the Tidy.pm module <stderr> parameter may
- not be a reference to SCALAR or ARRAY; it must be a file.
-
- - Syntax check with perl now work when the Tidy.pm module is processing
- references to arrays and strings. Thanks to Charles Alderman.
-
- - Zero-length files are no longer processed due to concerns for data loss
- due to side effects in some scenarios.
-
- - block labels, if any, are now included in closing side comment text
- when the -csc flag is used. Suggested by Aaron. For example,
- the label L102 in the following block is now included in the -csc text:
-
- L102: for my $i ( 1 .. 10 ) {
- ...
- } ## end L102: for my $i ( 1 .. 10 )</code></pre>
-
-<h2 id="pod2010-12-17">2010 12 17</h2>
-
-<pre><code> - added new flag -it=n or --iterations=n
- This flag causes perltidy to do n complete iterations.
- For most purposes the default of n=1 should be satisfactory. However n=2
- 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. The run time will be
- approximately proportional to n, and it should seldom be necessary to use a
- value greater than n=2. Thanks to Jonathan Swartz
-
- - A configuration file pathname begins with three dots, e.g.
- ".../.perltidyrc", 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.
- Thanks to Jonathan Swartz for this patch.
-
- - Added flag --notidy which disables all formatting and causes the input to be
- copied unchanged. This can be useful in conjunction with hierarchical
- F<.perltidyrc> files to prevent unwanted tidying.
- Thanks to Jonathan Swartz for this patch.
-
- - Added prefilters and postfilters in the call to the Tidy.pm module.
- Prefilters and postfilters. The prefilter is a code reference that
- will be applied to the source before tidying, and the postfilter
- is a code reference to the result before outputting.
-
- Thanks to Jonathan Swartz for this patch. He writes:
- This is useful for all manner of customizations. For example, I use
- it to convert the 'method' keyword to 'sub' so that perltidy will work for
- Method::Signature::Simple code:
-
- Perl::Tidy::perltidy(
- prefilter => sub { $_ = $_[0]; s/^method (.*)/sub $1 \#__METHOD/gm; return $_ },
- postfilter => sub { $_ = $_[0]; s/^sub (.*?)\s* \#__METHOD/method $1/gm; return $_ }
- );
-
- - The starting indentation level of sections of code entabbed with -et=n
- is correctly guessed if it was also produced with the same -et=n flag. This
- keeps the indentation stable on repeated formatting passes within an editor.
- Thanks to Sam Kington and Glenn.
-
- - Functions with prototype '&' had a space between the function and opening
- peren. This space now only occurs if the flag --space-function-paren (-sfp)
- is set. Thanks to Zrajm Akfohg.
-
- - Patch to never put spaces around a bare word in braces beginning with ^ as in:
- my $before = ${^PREMATCH};
- even if requested with the -bt=0 flag because any spaces cause a syntax error in perl.
- Thanks to Fabrice Dulanoy.</code></pre>
-
-<h2 id="pod2009-06-16">2009 06 16</h2>
-
-<pre><code> - Allow configuration file to be 'perltidy.ini' for Windows systems.
- i.e. C:\Documents and Settings\User\perltidy.ini
- and added documentation for setting configuation file under Windows in man
- page. Thanks to Stuart Clark.
-
- - Corrected problem of unwanted semicolons in hash ref within given/when code.
- Thanks to Nelo Onyiah.
-
- - added new flag -cscb or --closing-side-comments-balanced
- When using closing-side-comments, and the closing-side-comment-maximum-text
- limit is exceeded, then the comment text must be truncated. Previous
- versions of perltidy terminate with three dots, and this can still be
- achieved with -ncscb:
-
- perltidy -csc -ncscb
-
- } ## end foreach my $foo (sort { $b cmp $a ...
-
- However this causes a problem with older editors which cannot recognize
- comments or are not configured to doso because they cannot "bounce" around in
- the text correctly. The B<-cscb> flag tries to help them by
- appending appropriate terminal balancing structure:
-
- perltidy -csc -cscb
-
- } ## end foreach my $foo (sort { $b cmp $a ... })
-
- Since there is much to be gained and little to be lost by doing this,
- the default is B<-cscb>. Use B<-ncscb> if you do not want this.
-
- Thanks to Daniel Becker for suggesting this option.
-
- - After an isolated closing eval block the continuation indentation will be
- removed so that the braces line up more like other blocks. Thanks to Yves Orton.
-
- OLD:
- eval {
- #STUFF;
- 1; # return true
- }
- or do {
- #handle error
- };
-
- NEW:
- eval {
- #STUFF;
- 1; # return true
- } or do {
- #handle error
- };
-
- -A new flag -asbl (or --opening-anonymous-sub-brace-on-new-line) has
- been added to put the opening brace of anonymous sub's on a new line,
- as in the following snippet:
-
- my $code = sub
- {
- my $arg = shift;
- return $arg->(@_);
- };
-
- This was not possible before because the -sbl flag only applies to named
- subs. Thanks to Benjamin Krupp.
-
- -Fix tokenization bug with the following snippet
- print 'hi' if { x => 1, }->{x};
- which resulted in a semicolon being added after the comma. The workaround
- was to use -nasc, but this is no longer necessary. Thanks to Brian Duggan.
-
- -Fixed problem in which an incorrect error message could be triggered
- by the (unusual) combination of parameters -lp -i=0 -l=2 -ci=0 for
- example. Thanks to Richard Jelinek.
-
- -A new flag --keep-old-blank-lines=n has been added to
- give more control over the treatment of old blank lines in
- a script. The manual has been revised to discuss the new
- flag and clarify the treatment of old blank lines. Thanks
- to Oliver Schaefer.</code></pre>
-
-<h2 id="pod2007-12-05">2007 12 05</h2>
-
-<pre><code> -Improved support for perl 5.10: New quote modifier 'p', new block type UNITCHECK,
- new keyword break, improved formatting of given/when.
-
- -Corrected tokenization bug of something like $var{-q}.
-
- -Numerous minor formatting improvements.
-
- -Corrected list of operators controlled by -baao -bbao to include
- . : ? && || and or err xor
-
- -Corrected very minor error in log file involving incorrect comment
- regarding need for upper case of labels.
-
- -Fixed problem where perltidy could run for a very long time
- when given certain non-perl text files.
-
- -Line breaks in un-parenthesized lists now try to follow
- line breaks in the input file rather than trying to fill
- lines. This usually works better, but if this causes
- trouble you can use -iob to ignore any old line breaks.
- Example for the following input snippet:
-
- print
- "conformability (Not the same dimension)\n",
- "\t", $have, " is ", text_unit($hu), "\n",
- "\t", $want, " is ", text_unit($wu), "\n",
- ;
-
- OLD:
- print "conformability (Not the same dimension)\n", "\t", $have, " is ",
- text_unit($hu), "\n", "\t", $want, " is ", text_unit($wu), "\n",;
-
- NEW:
- print "conformability (Not the same dimension)\n",
- "\t", $have, " is ", text_unit($hu), "\n",
- "\t", $want, " is ", text_unit($wu), "\n",
- ;</code></pre>
-
-<h2 id="pod2007-08-01">2007 08 01</h2>
-
-<pre><code> -Added -fpsc option (--fixed-position-side-comment). Thanks to Ueli Hugenschmidt.
- For example -fpsc=40 tells perltidy to put side comments in column 40
- if possible.
-
- -Added -bbao and -baao options (--break-before-all-operators and
- --break-after-all-operators) to simplify command lines and configuration
- files. These define an initial preference for breaking at operators which can
- be modified with -wba and -wbb flags. For example to break before all operators
- except an = one could use --bbao -wba='=' rather than listing every
- single perl operator (except =) on a -wbb flag.
-
- -Added -kis option (--keep-interior-semicolons). Use the B<-kis> flag
- to prevent breaking at a semicolon if there was no break there in the
- input file. To illustrate, consider the following input lines:
-
- dbmclose(%verb_delim); undef %verb_delim;
- dbmclose(%expanded); undef %expanded;
- dbmclose(%global); undef %global;
-
- Normally these would be broken into six lines, but
- perltidy -kis gives:
-
- dbmclose(%verb_delim); undef %verb_delim;
- dbmclose(%expanded); undef %expanded;
- dbmclose(%global); undef %global;
-
- -Improved formatting of complex ternary statements, with indentation
- of nested statements.
- OLD:
- return defined( $cw->{Selected} )
- ? (wantarray)
- ? @{ $cw->{Selected} }
- : $cw->{Selected}[0]
- : undef;
-
- NEW:
- return defined( $cw->{Selected} )
- ? (wantarray)
- ? @{ $cw->{Selected} }
- : $cw->{Selected}[0]
- : undef;
-
- -Text following un-parenthesized if/unless/while/until statements get a
- full level of indentation. Suggested by Jeff Armstorng and others.
- OLD:
- return $ship->chargeWeapons("phaser-canon")
- if $encounter->description eq 'klingon'
- and $ship->firepower >= $encounter->firepower
- and $location->status ne 'neutral';
- NEW:
- return $ship->chargeWeapons("phaser-canon")
- if $encounter->description eq 'klingon'
- and $ship->firepower >= $encounter->firepower
- and $location->status ne 'neutral';</code></pre>
-
-<h2 id="pod2007-05-08">2007 05 08</h2>
-
-<pre><code> -Fixed bug where #line directives were being indented. Thanks to
- Philippe Bruhat.</code></pre>
-
-<h2 id="pod2007-05-04">2007 05 04</h2>
-
-<pre><code> -Fixed problem where an extra blank line was added after an =cut when either
- (a) the =cut started (not stopped) a POD section, or (b) -mbl > 1.
- Thanks to J. Robert Ray and Bill Moseley.</code></pre>
-
-<h2 id="pod2007-04-24">2007 04 24</h2>
-
-<pre><code> -ole (--output-line-ending) and -ple (--preserve-line-endings) should
- now work on all systems rather than just unix systems. Thanks to Dan
- Tyrell.
-
- -Fixed problem of a warning issued for multiple subs for BEGIN subs
- and other control subs. Thanks to Heiko Eissfeldt.
-
- -Fixed problem where no space was introduced between a keyword or
- bareword and a colon, such as:
-
- ( ref($result) eq 'HASH' && !%$result ) ? undef: $result;
-
- Thanks to Niek.
-
- -Added a utility program 'break_long_quotes.pl' to the examples directory of
- the distribution. It breaks long quoted strings into a chain of concatenated
- sub strings no longer than a selected length. Suggested by Michael Renner as
- a perltidy feature but was judged to be best done in a separate program.
-
- -Updated docs to remove extra < and >= from list of tokens
- after which breaks are made by default. Thanks to Bob Kleemann.
-
- -Removed improper uses of $_ to avoid conflicts with external calls, giving
- error message similar to:
- Modification of a read-only value attempted at
- /usr/share/perl5/Perl/Tidy.pm line 6907.
- Thanks to Michael Renner.
-
- -Fixed problem when errorfile was not a plain filename or filehandle
- in a call to Tidy.pm. The call
- perltidy(source => \$input, destination => \$output, errorfile => \$err);
- gave the following error message:
- Not a GLOB reference at /usr/share/perl5/Perl/Tidy.pm line 3827.
- Thanks to Michael Renner and Phillipe Bruhat.
-
- -Fixed problem where -sot would not stack an opening token followed by
- a side comment. Thanks to Jens Schicke.
-
- -improved breakpoints in complex math and other long statements. Example:
- OLD:
- return
- log($n) + 0.577215664901532 + ( 1 / ( 2 * $n ) ) -
- ( 1 / ( 12 * ( $n**2 ) ) ) + ( 1 / ( 120 * ( $n**4 ) ) );
- NEW:
- return
- log($n) + 0.577215664901532 +
- ( 1 / ( 2 * $n ) ) -
- ( 1 / ( 12 * ( $n**2 ) ) ) +
- ( 1 / ( 120 * ( $n**4 ) ) );
-
- -more robust vertical alignment of complex terminal else blocks and ternary
- statements.</code></pre>
-
-<h2 id="pod2006-07-19">2006 07 19</h2>
-
-<pre><code> -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern
- replacement text was not recognized. The tokenizer now recursively scans
- replacement text (but does not reformat it).
-
- -improved vertical alignment of terminal else blocks and ternary statements.
- Thanks to Chris for the suggestion.
-
- OLD:
- if ( IsBitmap() ) { return GetBitmap(); }
- elsif ( IsFiles() ) { return GetFiles(); }
- else { return GetText(); }
-
- NEW:
- if ( IsBitmap() ) { return GetBitmap(); }
- elsif ( IsFiles() ) { return GetFiles(); }
- else { return GetText(); }
-
- OLD:
- $which_search =
- $opts{"t"} ? 'title'
- : $opts{"s"} ? 'subject'
- : $opts{"a"} ? 'author'
- : 'title';
-
- NEW:
- $which_search =
- $opts{"t"} ? 'title'
- : $opts{"s"} ? 'subject'
- : $opts{"a"} ? 'author'
- : 'title';
-
- -improved indentation of try/catch blocks and other externally defined
- functions accepting a block argument. Thanks to jae.
-
- -Added support for Perl 5.10 features say and smartmatch.
-
- -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters
- suggested in Damian Conway's "Perl Best Practices". -pbp is the same as:
-
- -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
- -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < =
- **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
-
- Please note that the -st here restricts input to standard input; use
- -nst if necessary to override.
-
- -Eliminated some needless breaks at equals signs in -lp indentation.
-
- OLD:
- $c =
- Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
- TOP + $y * (BOTTOM - TOP) / SIZE);
- NEW:
- $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
- TOP + $y * (BOTTOM - TOP) / SIZE);
-
- A break at an equals is sometimes useful for preventing complex statements
- from hitting the line length limit. The decision to do this was
- over-eager in some cases and has been improved. Thanks to Royce Reece.
-
- -qw quotes contained in braces, square brackets, and parens are being
- treated more like those containers as far as stacking of tokens. Also
- stack of closing tokens ending ');' will outdent to where the ');' would
- have outdented if the closing stack is matched with a similar opening stack.
-
- OLD: perltidy -soc -sct
- __PACKAGE__->load_components(
- qw(
- PK::Auto
- Core
- )
- );
- NEW: perltidy -soc -sct
- __PACKAGE__->load_components( qw(
- PK::Auto
- Core
- ) );
- Thanks to Aran Deltac
-
- -Eliminated some undesirable or marginally desirable vertical alignments.
- These include terminal colons, opening braces, and equals, and particularly
- when just two lines would be aligned.
-
- OLD:
- my $accurate_timestamps = $Stamps{lnk};
- my $has_link =
- ...
- NEW:
- my $accurate_timestamps = $Stamps{lnk};
- my $has_link =
-
- -Corrected a problem with -mangle in which a space would be removed
- between a keyword and variable beginning with ::.</code></pre>
-
-<h2 id="pod2006-06-14">2006 06 14</h2>
-
-<pre><code> -Attribute argument lists are now correctly treated as quoted strings
- and not formatted. This is the most important update in this version.
- Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup.
-
- -Updated to recognize the defined or operator, //, to be released in Perl 10.
- Thanks to Sebastien Aperghis-Tramoni.
-
- -A useful utility perltidyrc_dump.pl is included in the examples section. It
- will read any perltidyrc file and write it back out in a standard format
- (though comments are lost).
-
- -Added option to have perltidy read and return a hash with the contents of a
- perltidyrc file. This may be used by Leif Eriksen's tidyview code. This
- feature is used by the demonstration program 'perltidyrc_dump.pl' in the
- examples directory.
-
- -Improved error checking in perltidyrc files. Unknown bare words were not
- being caught.
-
- -The --dump-options parameter now dumps parameters in the format required by a
- perltidyrc file.
-
- -V-Strings with underscores are now recognized.
- For example: $v = v1.2_3;
-
- -cti=3 option added which gives one extra indentation level to closing
- tokens always. This provides more predictable closing token placement
- than cti=2. If you are using cti=2 you might want to try cti=3.
-
- -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>.
-
- -New parameters -fs, -fsb, -fse added to allow sections of code between #<<<
- and #>>> to be passed through verbatim. This is enabled by default and turned
- off by -nfs. Flags -fsb and -fse allow other beginning and ending markers.
- Thanks to Wolfgang Werner and Marion Berryman for suggesting this.
-
- -added flag -skp to put a space between all Perl keywords and following paren.
- The default is to only do this for certain keywords. Suggested by
- H.Merijn Brand.
-
- -added flag -sfp to put a space between a function name and following paren.
- The default is not to do this. Suggested by H.Merijn Brand.
-
- -Added patch to avoid breaking GetOpt::Long::Configure set by calling program.
- Thanks to Philippe Bruhat.
-
- -An error was fixed in which certain parameters in a .perltidyrc file given
- without the equals sign were not recognized. That is,
- '--brace-tightness 0' gave an error but '--brace-tightness=0' worked
- ok. Thanks to Zac Hansen.
-
- -An error preventing the -nwrs flag from working was corrected. Thanks to
- Greg Ferguson.
-
- -Corrected some alignment problems with entab option.
-
- -A bug with the combination of -lp and -extrude was fixed (though this
- combination doesn't really make sense). The bug was that a line with
- a single zero would be dropped. Thanks to Cameron Hayne.
-
- -Updated Windows detection code to avoid an undefined variable.
- Thanks to Joe Yates and Russ Jones.
-
- -Improved formatting for short trailing statements following a closing paren.
- Thanks to Joe Matarazzo.
-
- -The handling of the -icb (indent closing block braces) flag has been changed
- slightly to provide more consistent and predictable formatting of complex
- structures. Instead of giving a closing block brace the indentation of the
- previous line, it is now given one extra indentation level. The two methods
- give the same result if the previous line was a complete statement, as in this
- example:
-
- if ($task) {
- yyy();
- } # -icb
- else {
- zzz();
- }
- The change also fixes a problem with empty blocks such as:
-
- OLD, -icb:
- elsif ($debug) {
- }
-
- NEW, -icb:
- elsif ($debug) {
- }
-
- -A problem with -icb was fixed in which a closing brace was misplaced when
- it followed a quote which spanned multiple lines.
-
- -Some improved breakpoints for -wba='&& || and or'
-
- -Fixed problem with misaligned cuddled else in complex statements
- when the -bar flag was also used. Thanks to Alex and Royce Reese.
-
- -Corrected documentation to show that --outdent-long-comments is the default.
- Thanks to Mario Lia.
-
- -New flag -otr (opening-token-right) is similar to -bar (braces-always-right)
- but applies to non-structural opening tokens.
-
- -new flags -sot (stack-opening-token), -sct (stack-closing-token).
- Suggested by Tony.</code></pre>
-
-<h2 id="pod2003-10-21">2003 10 21</h2>
-
-<pre><code> -The default has been changed to not do syntax checking with perl.
- Use -syn if you want it. Perltidy is very robust now, and the -syn
- flag now causes more problems than it's worth because of BEGIN blocks
- (which get executed with perl -c). For example, perltidy will never
- return when trying to beautify this code if -syn is used:
-
- BEGIN { 1 while { }; }
-
- Although this is an obvious error, perltidy is often run on untested
- code which is more likely to have this sort of problem. A more subtle
- example is:
-
- BEGIN { use FindBin; }
-
- which may hang on some systems using -syn if a shared file system is
- unavailable.
-
- -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item).
- In most cases it looks better. To recover the previous format, use
- '-gnu -cti=2'
-
- -Added flags -cti=n for finer control of closing token indentation.
- -cti = 0 no extra indentation (default; same as -nicp)
- -cti = 1 enough indentation so that the closing token
- aligns with its opening token.
- -cti = 2 one extra indentation level if the line has the form
- ); ]; or }; (same as -icp).
-
- The new option -cti=1 works well with -lp:
-
- EXAMPLES:
-
- # perltidy -lp -cti=1
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );
-
- # perltidy -lp -cti=2
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );
- This is backwards compatible with -icp. See revised manual for
- details. Suggested by Mike Pennington.
-
- -Added flag '--preserve-line-endings' or '-ple' to cause the output
- line ending to be the same as in the input file, for unix, dos,
- or mac line endings. Only works under unix. Suggested by
- Rainer Hochschild.
-
- -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win,
- unix, or mac. Only works under unix.
-
- -Files with Mac line endings should now be handled properly under unix
- and dos without being passed through a converter.
-
- -You may now include 'and', 'or', and 'xor' in the list following
- '--want-break-after' to get line breaks after those keywords rather than
- before them. Suggested by Rainer Hochschild.
-
- -Corrected problem with command line option for -vtc=n and -vt=n. The
- equals sign was being eaten up by the Windows shell so perltidy didn't
- see it.</code></pre>
-
-<h2 id="pod2003-07-26">2003 07 26</h2>
-
-<pre><code> -Corrected cause of warning message with recent versions of Perl:
- "Possible precedence problem on bitwise & operator at ..."
- Thanks to Jim Files.
-
- -fixed bug with -html with '=for pod2html' sections, in which code/pod
- output order was incorrect. Thanks to Tassilo von Parseval.
-
- -fixed bug when the -html flag is used, in which the following error
- message, plus others, appear:
- did not see <body> in pod2html output
- This was caused by a change in the format of html output by pod2html
- VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval.
-
- -Fixed bug where an __END__ statement would be mistaken for a label
- if it is immediately followed by a line with a leading colon. Thanks
- to John Bayes.
-
- -Implemented guessing logic for brace types when it is ambiguous. This
- has been on the TODO list a long time. Thanks to Boris Zentner for
- an example.
-
- -Long options may now be negated either as '--nolong-option'
- or '--no-long-option'. Thanks to Philip Newton for the suggestion.
-
- -added flag --html-entities or -hent which controls the use of
- Html::Entities for html formatting. Use --nohtml-entities or -nhent to
- prevent the use of Html::Entities to encode special symbols. The
- default is -hent. Html::Entities when formatting perl text to escape
- special symbols. This may or may not be the right thing to do,
- depending on browser/language combinations. Thanks to Burak Gursoy for
- this suggestion.
-
- -Bareword strings with leading '-', like, '-foo' now count as 1 token
- for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo}
- are now all treated similarly. Thus, by default, OLD: $a{ -foo } will
- now be NEW: $a{-foo}. Suggested by Mark Olesen.
-
- -added 2 new flags to control spaces between keywords and opening parens:
- -sak=s or --space-after-keyword=s, and
- -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords.
-
- The new default list of keywords which get a space is:
-
- "my local our and or eq ne if else elsif until unless while for foreach
- return switch case given when"
-
- Use -sak=s and -nsak=s to add and remove keywords from this list,
- respectively.
-
- Explanation: Stephen Hildrey noted that perltidy was being inconsistent
- in placing spaces between keywords and opening parens, and sent a patch
- to give user control over this. The above list was selected as being
- a reasonable default keyword list. Previously, perltidy
- had a hardwired list which also included these keywords:
-
- push pop shift unshift join split die
-
- but did not have 'our'. Example: if you prefer to make perltidy behave
- exactly as before, you can include the following two lines in your
- .perltidyrc file:
-
- -sak="push pop local shift unshift join split die"
- -nsak="our"
-
- -Corrected html error in .toc file when -frm -html is used (extra ");
- browsers were tolerant of it.
-
- -Improved alignment of chains of binary and ?/: operators. Example:
- OLD:
- $leapyear =
- $year % 4 ? 0
- : $year % 100 ? 1
- : $year % 400 ? 0
- : 1;
- NEW:
- $leapyear =
- $year % 4 ? 0
- : $year % 100 ? 1
- : $year % 400 ? 0
- : 1;
-
- -improved breakpoint choices involving '->'
-
- -Corrected tokenization of things like ${#}. For example,
- ${#} is valid, but ${# } is a syntax error.
-
- -Corrected minor tokenization errors with indirect object notation.
- For example, 'new A::()' works now.
-
- -Minor tokenization improvements; all perl code distributed with perl 5.8
- seems to be parsed correctly except for one instance (lextest.t)
- of the known bug.</code></pre>
-
-<h2 id="pod2002-11-30">2002 11 30</h2>
-
-<pre><code> -Implemented scalar attributes. Thanks to Sean Tobin for noting this.
-
- -Fixed glitch introduced in previous release where -pre option
- was not outputting a leading html <pre> tag.
-
- -Numerous minor improvements in vertical alignment, including the following:
-
- -Improved alignment of opening braces in many cases. Needed for improved
- switch/case formatting, and also suggested by Mark Olesen for sort/map/grep
- formatting. For example:
-
- OLD:
- @modified =
- map { $_->[0] }
- sort { $a->[1] <=> $b->[1] }
- map { [ $_, -M ] } @filenames;
-
- NEW:
- @modified =
- map { $_->[0] }
- sort { $a->[1] <=> $b->[1] }
- map { [ $_, -M ] } @filenames;
-
- -Eliminated alignments across unrelated statements. Example:
- OLD:
- $borrowerinfo->configure( -state => 'disabled' );
- $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
-
- NEW:
- $borrowerinfo->configure( -state => 'disabled' );
- $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
-
- Thanks to Mark Olesen for suggesting this.
-
- -Improved alignement of '='s in certain cases.
- Thanks to Norbert Gruener for sending an example.
-
- -Outdent-long-comments (-olc) has been re-instated as a default, since
- it works much better now. Use -nolc if you want to prevent it.
-
- -Added check for 'perltidy file.pl -o file.pl', which causes file.pl
- to be lost. (The -b option should be used instead). Thanks to mreister
- for reporting this problem.</code></pre>
-
-<h2 id="pod2002-11-06">2002 11 06</h2>
-
-<pre><code> -Switch/case or given/when syntax is now recognized. Its vertical alignment
- is not great yet, but it parses ok. The words 'switch', 'case', 'given',
- and 'when' are now treated as keywords. If this causes trouble with older
- code, we could introduce a switch to deactivate it. Thanks to Stan Brown
- and Jochen Schneider for recommending this.
-
- -Corrected error parsing sub attributes with call parameters.
- Thanks to Marc Kerr for catching this.
-
- -Sub prototypes no longer need to be on the same line as sub names.
-
- -a new flag -frm or --frames will cause html output to be in a
- frame, with table of contents in the left panel and formatted source
- in the right panel. Try 'perltidy -html -frm somemodule.pm' for example.
-
- -The new default for -html formatting is to pass the pod through Pod::Html.
- The result is syntax colored code within your pod documents. This can be
- deactivated with -npod. Thanks to those who have written to discuss this,
- particularly Mark Olesen and Hugh Myers.
-
- -the -olc (--outdent-long-comments) option works much better. It now outdents
- groups of consecutive comments together, and by just the amount needed to
- avoid having any one line exceeding the maximum line length.
-
- -block comments are now trimmed of trailing whitespace.
-
- -if a directory specified with -opath does not exist, it will be created.
-
- -a table of contents to packages and subs is output when -html is used.
- Use -ntoc to prevent this.
-
- -fixed an unusual bug in which a 'for' statement following a 'format'
- statement was not correctly tokenized. Thanks to Boris Zentner for
- catching this.
-
- -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray.
- There were some speed issues. Suggested by Joerg Walter.
-
- -The treatment of quoted wildcards (file globs) is now system-independent.
- For example
-
- perltidy 'b*x.p[lm]'
-
- would match box.pl, box.pm, brinx.pm under any operating system. Of
- course, anything unquoted will be subject to expansion by any shell.
-
- -default color for keywords under -html changed from
- SaddleBrown (#8B4513) to magenta4 (#8B008B).
-
- -fixed an arg parsing glitch in which something like:
- perltidy quick-help
- would trigger the help message and exit, rather than operate on the
- file 'quick-help'.</code></pre>
-
-<h2 id="pod2002-09-22">2002 09 22</h2>
-
-<pre><code> -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to
- overwrite the original file with the tidied output file. The original
- file will be saved with a '.bak' extension (which can be changed with
- -bext=s). Thanks to Rudi Farkas for the suggestion.
-
- -An index to all subs is included at the top of -html output, unless
- only the <pre> section is written.
-
- -Anchor lines of the form <a name="mysub"></a> are now inserted at key points
- in html output, such as before sub definitions, for the convenience of
- postprocessing scripts. Suggested by Howard Owen.
-
- -The cuddled-else (-ce) flag now also makes cuddled continues, like
- this:
-
- while ( ( $pack, $file, $line ) = caller( $i++ ) ) {
- # bla bla
- } continue {
- $prevpack = $pack;
- }
-
- Suggested by Simon Perreault.
-
- -Fixed bug in which an extra blank line was added before an =head or
- similar pod line after an __END__ or __DATA__ line each time
- perltidy was run. Also, an extra blank was being added after
- a terminal =cut. Thanks to Mike Birdsall for reporting this.</code></pre>
-
-<h2 id="pod2002-08-26">2002 08 26</h2>
-
-<pre><code> -Fixed bug in which space was inserted in a hyphenated hash key:
- my $val = $myhash{USER-NAME};
- was converted to:
- my $val = $myhash{USER -NAME};
- Thanks to an anonymous bug reporter at sourceforge.
-
- -Fixed problem with the '-io' ('--indent-only') where all lines
- were double spaced. Thanks to Nick Andrew for reporting this bug.
-
- -Fixed tokenization error in which something like '-e1' was
- parsed as a number.
-
- -Corrected a rare problem involving older perl versions, in which
- a line break before a bareword caused problems with 'use strict'.
- Thanks to Wolfgang Weisselberg for noting this.
-
- -More syntax error checking added.
-
- -Outdenting labels (-ola) has been made the default, in order to follow the
- perlstyle guidelines better. It's probably a good idea in general, but
- if you do not want this, use -nola in your .perltidyrc file.
-
- -Updated rules for padding logical expressions to include more cases.
- Thanks to Wolfgang Weisselberg for helpful discussions.
-
- -Added new flag -osbc (--outdent-static-block-comments) which will
- outdent static block comments by 2 spaces (or whatever -ci equals).
- Requested by Jon Robison.</code></pre>
-
-<h2 id="pod2002-04-25">2002 04 25</h2>
-
-<pre><code> -Corrected a bug, introduced in the previous release, in which some
- closing side comments (-csc) could have incorrect text. This is
- annoying but will be correct the next time perltidy is run with -csc.
-
- -Fixed bug where whitespace was being removed between 'Bar' and '()'
- in a use statement like:
-
- use Foo::Bar ();
-
- -Whenever possible, if a logical expression is broken with leading
- '&&', '||', 'and', or 'or', then the leading line will be padded
- with additional space to produce alignment. This has been on the
- todo list for a long time; thanks to Frank Steinhauer for reminding
- me to do it. Notice the first line after the open parens here:
-
- OLD: perltidy -lp
- if (
- !param("rules.to.$linecount")
- && !param("rules.from.$linecount")
- && !param("rules.subject.$linecount")
- && !(
- param("rules.fieldname.$linecount")
- && param("rules.fieldval.$linecount")
- )
- && !param("rules.size.$linecount")
- && !param("rules.custom.$linecount")
- )
-
- NEW: perltidy -lp
- if (
- !param("rules.to.$linecount")
- && !param("rules.from.$linecount")
- && !param("rules.subject.$linecount")
- && !(
- param("rules.fieldname.$linecount")
- && param("rules.fieldval.$linecount")
- )
- && !param("rules.size.$linecount")
- && !param("rules.custom.$linecount")
- )</code></pre>
-
-<h2 id="pod2002-04-16">2002 04 16</h2>
-
-<pre><code> -Corrected a mistokenization of variables for a package with a name
- equal to a perl keyword. For example:
-
- my::qx();
- package my;
- sub qx{print "Hello from my::qx\n";}
-
- In this case, the leading 'my' was mistokenized as a keyword, and a
- space was being place between 'my' and '::'. This has been
- corrected. Thanks to Martin Sluka for discovering this.
-
- -A new flag -bol (--break-at-old-logic-breakpoints)
- has been added to control whether containers with logical expressions
- should be broken open. This is the default.
-
- -A new flag -bok (--break-at-old-keyword-breakpoints)
- has been added to follow breaks at old keywords which return lists,
- such as sort and map. This is the default.
-
- -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to
- follow breaks at trinary (conditional) operators. This is the default.
-
- -A new flag -cab=n has been added to control breaks at commas after
- '=>' tokens. The default is n=1, meaning break unless this breaks
- open an existing on-line container.
-
- -A new flag -boc has been added to allow existing list formatting
- to be retained. (--break-at-old-comma-breakpoints). See updated manual.
-
- -A new flag -iob (--ignore-old-breakpoints) has been added to
- prevent the locations of old breakpoints from influencing the output
- format.
-
- -Corrected problem where nested parentheses were not getting full
- indentation. This has been on the todo list for some time; thanks
- to Axel Rose for a snippet demonstrating this issue.
-
- OLD: inner list is not indented
- $this->sendnumeric(
- $this->server,
- (
- $ret->name, $user->username, $user->host,
- $user->server->name, $user->nick, "H"
- ),
- );
-
- NEW:
- $this->sendnumeric(
- $this->server,
- (
- $ret->name, $user->username, $user->host,
- $user->server->name, $user->nick, "H"
- ),
- );
-
- -Code cleaned up by removing the following unused, undocumented flags.
- They should not be in any .perltidyrc files because they were just
- experimental flags which were never documented. Most of them placed
- artificial limits on spaces, and Wolfgang Weisselberg convinced me that
- most of them they do more harm than good by causing unexpected results.
-
- --maximum-continuation-indentation (-mci)
- --maximum-whitespace-columns
- --maximum-space-to-comment (-xsc)
- --big-space-jump (-bsj)
-
- -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and
- Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's
- were having trouble.
-
- -A new flag -isbc has been added for more control on comments. This flag
- has the effect that if there is no leading space on the line, then the
- comment will not be indented, and otherwise it may be. If both -ibc and
- -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer
- for suggesting this.
-
- -A new document 'stylekey.pod' has been created to quickly guide new users
- through the maze of perltidy style parameters. An html version is
- on the perltidy web page. Take a look! It should be very helpful.
-
- -Parameters for controlling 'vertical tightness' have been added:
- -vt and -vtc are the main controls, but finer control is provided
- with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical
- tightness controls have also been added.
- See updated manual and also see 'stylekey.pod'. Simple examples:
-
- # perltidy -lp -vt=1 -vtc=1
- @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
-
- # perltidy -lp -vt=1 -vtc=0
- @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );
-
- -Lists which do not format well in uniform columns are now better
- identified and formated.
-
- OLD:
- return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'},
- $y + $ruler_info{'size'}, $x - $ruler_info{'size'},
- $y + $ruler_info{'size'} );
-
- NEW:
- return $c->create(
- 'polygon', $x, $y,
- $x + $ruler_info{'size'},
- $y + $ruler_info{'size'},
- $x - $ruler_info{'size'},
- $y + $ruler_info{'size'}
- );
-
- OLD:
- radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ',
- 'None', 'Default', 'Default', 'Simple', 'Simple');
- NEW:
- radlablist($f1,
- pad('Initial', $p),
- $b->{Init}->get_panel_ref,
- 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple');
-
- -Corrected problem where an incorrect html filename was generated for
- external calls to Tidy.pm module. Fixed incorrect html title when
- Tidy.pm is called with IO::Scalar or IO::Array source.
-
- -Output file permissons are now set as follows. An output script file
- gets the same permission as the input file, except that owner
- read/write permission is added (otherwise, perltidy could not be
- rerun). Html output files use system defaults. Previously chmod 0755
- was used in all cases. Thanks to Mark Olesen for bringing this up.
-
- -Missing semicolons will not be added in multi-line blocks of type
- sort, map, or grep. This brings perltidy into closer agreement
- with common practice. Of course, you can still put semicolons
- there if you like. Thanks to Simon Perreault for a discussion of this.
-
- -Most instances of extra semicolons are now deleted. This is
- particularly important if the -csc option is used. Thanks to Wolfgang
- Weisselberg for noting this. For example, the following line
- (produced by 'h2xs' :) has an extra semicolon which will now be
- removed:
-
- BEGIN { plan tests => 1 };
-
- -New parameter -csce (--closing-side-comment-else-flag) can be used
- to control what text is appended to 'else' and 'elsif' blocks.
- Default is to just add leading 'if' text to an 'else'. See manual.
-
- -The -csc option now labels 'else' blocks with additinal information
- from the opening if statement and elsif statements, if space.
- Thanks to Wolfgang Weisselberg for suggesting this.
-
- -The -csc option will now remove any old closing side comments
- below the line interval threshold. Thanks to Wolfgang Weisselberg for
- suggesting this.
-
- -The abbreviation feature, which was broken in the previous version,
- is now fixed. Thanks to Michael Cartmell for noting this.
-
- -Vertical alignment is now done for '||=' .. somehow this was
- overlooked.</code></pre>
-
-<h2 id="pod2002-02-25">2002 02 25</h2>
-
-<pre><code> -This version uses modules for the first time, and a standard perl
- Makefile.PL has been supplied. However, perltidy may still be
- installed as a single script, without modules. See INSTALL for
- details.
-
- -The man page 'perl2web' has been merged back into the main 'perltidy'
- man page to simplify installation. So you may remove that man page
- if you have an older installation.
-
- -Added patch from Axel Rose for MacPerl. The patch prompts the user
- for command line arguments before calling the module
- Perl::Tidy::perltidy.
-
- -Corrected bug with '-bar' which was introduced in the previous
- version. A closing block brace was being indented. Thanks to
- Alexandros M Manoussakis for reporting this.
-
- -New parameter '--entab-leading-whitespace=n', or '-et=n', has been
- added for those who prefer tabs. This behaves different from the
- existing '-t' parameter; see updated man page. Suggested by Mark
- Olesen.
-
- -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be
- used to change the flags passed to perltidy in a syntax check.
- See updated man page. Suggested by Mark Olesen.
-
- -New parameter '--output-path=s' or '-opath=s' will cause output
- files to be placed in directory s. See updated man page. Thanks for
- Mark Olesen for suggesting this.
-
- -New parameter --dump-profile (or -dpro) will dump to
- standard output information about the search for a
- configuration file, the name of whatever configuration file
- is selected, and its contents. This should help debugging
- config files, especially on different Windows systems.
-
- -The -w parameter now notes possible errors of the form:
-
- $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace
-
- -Corrections added for a leading ':' and for leaving a leading 'tcsh'
- line untouched. Mark Olesen reported that lines of this form were
- accepted by perl but not by perltidy:
-
- : # use -*- perl -*-
- eval 'exec perl -wS $0 "$@"' # shell should exec 'perl'
- unless 1; # but Perl should skip this one
-
- Perl will silently swallow a leading colon on line 1 of a
- script, and now perltidy will do likewise. For example,
- this is a valid script, provided that it is the first line,
- but not otherwise:
-
- : print "Hello World\n";
-
- Also, perltidy will now mark a first line with leading ':' followed by
- '#' as type SYSTEM (just as a #! line), not to be formatted.
-
- -List formatting improved for certain lists with special
- initial terms, such as occur with 'printf', 'sprintf',
- 'push', 'pack', 'join', 'chmod'. The special initial term is
- now placed on a line by itself. For example, perltidy -gnu
-
- OLD:
- $Addr = pack(
- "C4", hex($SourceAddr[0]),
- hex($SourceAddr[1]), hex($SourceAddr[2]),
- hex($SourceAddr[3])
- );
-
- NEW:
- $Addr = pack("C4",
- hex($SourceAddr[0]), hex($SourceAddr[1]),
- hex($SourceAddr[2]), hex($SourceAddr[3]));
-
- OLD:
- push (
- @{$$self{states}}, '64', '66', '68',
- '70', '72', '74', '76',
- '78', '80', '82', '84',
- '86', '88', '90', '92',
- '94', '96', '98', '100',
- '102', '104'
- );
-
- NEW:
- push (
- @{$$self{states}},
- '64', '66', '68', '70', '72', '74', '76',
- '78', '80', '82', '84', '86', '88', '90',
- '92', '94', '96', '98', '100', '102', '104'
- );
-
- -Lists of complex items, such as matricies, are now detected
- and displayed with just one item per row:
-
- OLD:
- $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
- [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ],
- [ 0, 0, 1 ]
- );
-
- NEW:
- $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
- [ 1, tan( deg2rad($a) ), 0 ],
- [ tan( deg2rad($b) ), 1, 0 ],
- [ 0, 0, 1 ]
- );
-
- -The perl syntax check will be turned off for now when input is from
- standard input or standard output. The reason is that this requires
- temporary files, which has produced far too many problems during
- Windows testing. For example, the POSIX module under Windows XP/2000
- creates temporary names in the root directory, to which only the
- administrator should have permission to write.
-
- -Merged patch sent by Yves Orton to handle appropriate
- configuration file locations for different Windows varieties
- (2000, NT, Me, XP, 95, 98).
-
- -Added patch to properly handle a for/foreach loop without
- parens around a list represented as a qw. I didn't know this
- was possible until Wolfgang Weisselberg pointed it out:
-
- foreach my $key qw\Uno Due Tres Quadro\ {
- print "Set $key\n";
- }
-
- But Perl will give a syntax error without the $ variable; ie this will
- not work:
-
- foreach qw\Uno Due Tres Quadro\ {
- print "Set $_\n";
- }
-
- -Merged Windows version detection code sent by Yves Orton. Perltidy
- now automatically turns off syntax checking for Win 9x/ME versions,
- and this has solved a lot of robustness problems. These systems
- cannot reliably handle backtick operators. See man page for
- details.
-
- -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid
- output filenames were being created in some cases).
-
- -Numerous minor improvements have been made for -lp style indentation.
-
- -Long C-style 'for' expressions will be broken after each ';'.
-
- 'perltidy -gnu' gives:
-
- OLD:
- for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0
- and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()))
-
- NEW:
- for ($status = $db->seq($key, $value, R_CURSOR()) ;
- $status == 0 and $key eq $origkey ;
- $status = $db->seq($key, $value, R_NEXT()))
-
- -For the -lp option, a single long term within parens
- (without commas) now has better alignment. For example,
- perltidy -gnu
-
- OLD:
- $self->throw("Must specify a known host, not $location,"
- . " possible values ("
- . join (",", sort keys %hosts) . ")");
-
- NEW:
- $self->throw("Must specify a known host, not $location,"
- . " possible values ("
- . join (",", sort keys %hosts) . ")");</code></pre>
-
-<h2 id="pod2001-12-31">2001 12 31</h2>
-
-<pre><code> -This version is about 20 percent faster than the previous
- version as a result of optimization work. The largest gain
- came from switching to a dispatch hash table in the
- tokenizer.
-
- -perltidy -html will check to see if HTML::Entities is
- installed, and if so, it will use it to encode unsafe
- characters.
-
- -Added flag -oext=ext to change the output file extension to
- be different from the default ('tdy' or 'html'). For
- example:
-
- perltidy -html -oext=htm filename
-
- will produce filename.htm
-
- -Added flag -cscw to issue warnings if a closing side comment would replace
- an existing, different side comments. See the man page for details.
- Thanks to Peter Masiar for helpful discussions.
-
- -Corrected tokenization error of signed hex/octal/binary numbers. For
- example, the first hex number below would have been parsed correctly
- but the second one was not:
- if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { }
-
- -'**=' was incorrectly tokenized as '**' and '='. This only
- caused a problem with the -extrude opton.
-
- -Corrected a divide by zero when -extrude option is used
-
- -The flag -w will now contain all errors reported by 'perl -c' on the
- input file, but otherwise they are not reported. The reason is that
- perl will report lots of problems and syntax errors which are not of
- interest when only a small snippet is being formatted (such as missing
- modules and unknown bare words). Perltidy will always report all
- significant syntax errors that it finds, such as unbalanced braces,
- unless the -q (quiet) flag is set.
-
- -Merged modifications created by Hugh Myers into perltidy.
- These include a 'streamhandle' routine which allows perltidy
- as a module to operate on input and output arrays and strings
- in addition to files. Documentation and new packaging as a
- module should be ready early next year; This is an elegant,
- powerful update; many thanks to Hugh for contributing it.</code></pre>
-
-<h2 id="pod2001-11-28">2001 11 28</h2>
-
-<pre><code> -added a tentative patch which tries to keep any existing breakpoints
- at lines with leading keywords map,sort,eval,grep. The idea is to
- improve formatting of sequences of list operations, as in a schwartzian
- transform. Example:
-
- INPUT:
- my @sorted = map { $_->[0] }
- sort { $a->[1] <=> $b->[1] }
- map { [ $_, rand ] } @list;
-
- OLD:
- my @sorted =
- map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
-
- NEW:
- my @sorted = map { $_->[0] }
- sort { $a->[1] <=> $b->[1] }
- map { [ $_, rand ] } @list;
-
- The new alignment is not as nice as the input, but this is an improvement.
- Thanks to Yves Orton for this suggestion.
-
- -modified indentation logic so that a line with leading opening paren,
- brace, or square bracket will never have less indentation than the
- line with the corresponding opening token. Here's a simple example:
-
- OLD:
- $mw->Button(
- -text => "New Document",
- -command => \&new_document
- )->pack(
- -side => 'bottom',
- -anchor => 'e'
- );
-
- Note how the closing ');' is lined up with the first line, even
- though it closes a paren in the 'pack' line. That seems wrong.
-
- NEW:
- $mw->Button(
- -text => "New Document",
- -command => \&new_document
- )->pack(
- -side => 'bottom',
- -anchor => 'e'
- );
-
- This seems nicer: you can up-arrow with an editor and arrive at the
- opening 'pack' line.
-
- -corrected minor glitch in which cuddled else (-ce) did not get applied
- to an 'unless' block, which should look like this:
-
- unless ($test) {
-
- } else {
-
- }
-
- Thanks to Jeremy Mates for reporting this.
-
- -The man page has been reorganized to parameters easier to find.
-
- -Added check for multiple definitions of same subroutine. It is easy
- to introduce this problem when cutting and pasting. Perl does not
- complain about it, but it can lead to disaster.
-
- -The command -pro=filename or -profile=filename 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 '=' sign. I needed
- this to be able to easily test perltidy with a variety of different
- configuration files.
-
- -Side comment alignment has been improved somewhat across frequent level
- changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg
- for pointing out this problem. For example:
-
- OLD:
- if ( ref $self ) { # Called as a method
- $format = shift;
- }
- else { # Regular procedure call
- $format = $self;
- undef $self;
- }
-
- NEW:
- if ( ref $self ) { # Called as a method
- $format = shift;
- }
- else { # Regular procedure call
- $format = $self;
- undef $self;
- }
-
- -New command -ssc (--static-side-comment) and related command allows
- side comments to be spaced close to preceding character. This is
- useful for displaying commented code as side comments.
-
- -New command -csc (--closing-side-comment) and several related
- commands allow comments to be added to (and deleted from) any or all
- closing block braces. This can be useful if you have to maintain large
- programs, especially those that you didn't write. See updated man page.
- Thanks to Peter Masiar for this suggestion. For a simple example:
-
- perltidy -csc
-
- sub foo {
- if ( !defined( $_[0] ) ) {
- print("Hello, World\n");
- }
- else {
- print( $_[0], "\n" );
- }
- } ## end sub foo
-
- This added '## end sub foo' to the closing brace.
- To remove it, perltidy -ncsc.
-
- -New commands -ola, for outdenting labels, and -okw, for outdenting
- selected control keywords, were implemented. See the perltidy man
- page for details. Thanks to Peter Masiar for this suggestion.
-
- -Hanging side comment change: a comment will not be considered to be a
- hanging side comment if there is no leading whitespace on the line.
- This should improve the reliability of identifying hanging side comments.
- Thanks to Peter Masiar for this suggestion.
-
- -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc
- (outdent-long-comments), have been added. The original -oll
- (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc.
- The new default is just -olq. This was necessary to avoid inconsistency with
- the new static block comment option.
-
- -Static block comments: to provide a way to display commented code
- better, the convention is used that comments with a leading '##' should
- not be formatted as usual. Please see '-sbc' (or '--static-block-comment')
- for documentation. It can be deactivated with with -nsbc, but
- should not normally be necessary. Thanks to Peter Masiar for this
- suggestion.
-
- -Two changes were made to help show structure of complex lists:
- (1) breakpoints are forced after every ',' in a list where any of
- the list items spans multiple lines, and
- (2) List items which span multiple lines now get continuation indentation.
-
- The following example illustrates both of these points. Many thanks to
- Wolfgang Weisselberg for this snippet and a discussion of it; this is a
- significant formatting improvement. Note how it is easier to see the call
- parameters in the NEW version:
-
- OLD:
- assert( __LINE__, ( not defined $check )
- or ref $check
- or $check eq "new"
- or $check eq "old", "Error in parameters",
- defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
- defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
- defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" );
-
- NEW:
- assert(
- __LINE__,
- ( not defined $check )
- or ref $check
- or $check eq "new"
- or $check eq "old",
- "Error in parameters",
- defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
- defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
- defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef"
- );
-
- Another example shows how this helps displaying lists:
-
- OLD:
- %{ $self->{COMPONENTS} } = (
- fname =>
- { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
- street =>
- { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
- );
-
- The structure is clearer with the added indentation:
-
- NEW:
- %{ $self->{COMPONENTS} } = (
- fname =>
- { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
- street =>
- { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
- );
-
- -The structure of nested logical expressions is now displayed better.
- Thanks to Wolfgang Weisselberg for helpful discussions. For example,
- note how the status of the final 'or' is displayed in the following:
-
- OLD:
- return ( !null($op)
- and null( $op->sibling )
- and $op->ppaddr eq "pp_null"
- and class($op) eq "UNOP"
- and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/
- and $op->first->first->sibling->ppaddr eq "pp_lineseq" )
- or ( $op->first->ppaddr eq "pp_lineseq"
- and not null $op->first->first->sibling
- and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) );
-
- NEW:
- return (
- !null($op)
- and null( $op->sibling )
- and $op->ppaddr eq "pp_null"
- and class($op) eq "UNOP"
- and (
- (
- $op->first->ppaddr =~ /^pp_(and|or)$/
- and $op->first->first->sibling->ppaddr eq "pp_lineseq"
- )
- or ( $op->first->ppaddr eq "pp_lineseq"
- and not null $op->first->first->sibling
- and $op->first->first->sibling->ppaddr eq "pp_unstack" )
- )
- );
-
- -A break will always be put before a list item containing a comma-arrow.
- This will improve formatting of mixed lists of this form:
-
- OLD:
- $c->create(
- 'text', 225, 20, -text => 'A Simple Plot',
- -font => $font,
- -fill => 'brown'
- );
-
- NEW:
- $c->create(
- 'text', 225, 20,
- -text => 'A Simple Plot',
- -font => $font,
- -fill => 'brown'
- );
-
- -For convenience, the command -dac (--delete-all-comments) now also
- deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod
- to a '.TEE' file. Complete control over the treatment of pod and
- comments is still possible, as described in the updated help message
- and man page.
-
- -The logic which breaks open 'containers' has been rewritten to be completely
- symmetric in the following sense: if a line break is placed after an opening
- {, [, or (, then a break will be placed before the corresponding closing
- token. Thus, a container either remains closed or is completely cracked
- open.
-
- -Improved indentation of parenthesized lists. For example,
-
- OLD:
- $GPSCompCourse =
- int(
- atan2( $GPSTempCompLong - $GPSLongitude,
- $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 );
-
- NEW:
- $GPSCompCourse = int(
- atan2(
- $GPSTempCompLong - $GPSLongitude,
- $GPSLatitude - $GPSTempCompLat
- ) * 180 / 3.14159265
- );
-
- Further improvements will be made in future releases.
-
- -Some improvements were made in formatting small lists.
-
- -Correspondence between Input and Output line numbers reported in a
- .LOG file should now be exact. They were sometimes off due to the size
- of intermediate buffers.
-
- -Corrected minor tokenization error in which a ';' in a foreach loop
- control was tokenized as a statement termination, which forced a
- line break:
-
- OLD:
- foreach ( $i = 0;
- $i <= 10;
- $i += 2
- )
- {
- print "$i ";
- }
-
- NEW:
- foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) {
- print "$i ";
- }
-
- -Corrected a problem with reading config files, in which quote marks were not
- stripped. As a result, something like -wba="&& . || " would have the leading
- quote attached to the && and not work correctly. A workaround for older
- versions is to place a space around all tokens within the quotes, like this:
- -wba=" && . || "
-
- -Removed any existing space between a label and its ':'
- OLD : { }
- NEW: { }
- This was necessary because the label and its colon are a single token.
-
- -Corrected tokenization error for the following (highly non-recommended)
- construct:
- $user = @vars[1] / 100;
-
- -Resolved cause of a difference between perltidy under perl v5.6.1 and
- 5.005_03; the problem was different behavior of \G regex position
- marker(!)</code></pre>
-
-<h2 id="pod2001-10-20">2001 10 20</h2>
-
-<pre><code> -Corrected a bug in which a break was not being made after a full-line
- comment within a short eval/sort/map/grep block. A flag was not being
- zeroed. The syntax error check catches this. Here is a snippet which
- illustrates the bug:
-
- eval {
- #open Socket to Dispatcher
- $sock = &OpenSocket;
- };
-
- The formatter mistakenly thought that it had found the following
- one-line block:
-
- eval {#open Socket to Dispatcher$sock = &OpenSocket; };
-
- The patch fixes this. Many thanks to Henry Story for reporting this bug.
-
- -Changes were made to help diagnose and resolve problems in a
- .perltidyrc file:
- (1) processing of command parameters has been into two separate
- batches so that any errors in a .perltidyrc file can be localized.
- (2) commands --help, --version, and as many of the --dump-xxx
- commands are handled immediately, without any command line processing
- at all.
- (3) Perltidy will ignore any commands in the .perltidyrc file which
- cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt
- -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful
- suggestions regarding these updates.
-
- -Syntax check has been reinstated as default for MSWin32 systems. This
- way Windows 2000 users will get syntax check by default, which seems
- like a better idea, since the number of Win 95/98 systems will be
- decreasing over time. Documentation revised to warn Windows 95/98
- users about the problem with empty '&1'. Too bad these systems
- all report themselves as MSWin32.</code></pre>
-
-<h2 id="pod2001-10-16">2001 10 16</h2>
-
-<pre><code> -Fixed tokenization error in which a method call of the form
-
- Module::->new();
-
- got a space before the '::' like this:
-
- Module ::->new();
-
- Thanks to David Holden for reporting this.
-
- -Added -html control over pod text, using a new abbreviation 'pd'. See
- updated perl2web man page. The default is to use the color of a comment,
- but italicized. Old .css style sheets will need a new line for
- .pd to use this. The old color was the color of a string, and there
- was no control.
-
- -.css lines are now printed in sorted order.
-
- -Fixed interpolation problem where html files had '$input_file' as title
- instead of actual input file name. Thanks to Simon Perreault for finding
- this and sending a patch, and also to Tobias Weber.
-
- -Breaks will now have the ':' placed at the start of a line,
- one per line by default because this shows logical structure
- more clearly. This coding has been completely redone. Some
- examples of new ?/: formatting:
-
- OLD:
- wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) :
- $dir::cwd->lookup( $_[0] )->path;
-
- NEW:
- wantarray
- ? map( $dir::cwd->lookup($_)->path, @_ )
- : $dir::cwd->lookup( $_[0] )->path;
-
- OLD:
- $a = ( $b > 0 ) ? {
- a => 1,
- b => 2
- } : { a => 6, b => 8 };
-
- NEW:
- $a = ( $b > 0 )
- ? {
- a => 1,
- b => 2
- }
- : { a => 6, b => 8 };
-
- OLD: (-gnu):
- $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" :
- "Hunk #$self->{hunk} failed--$@");
-
- NEW: (-gnu):
- $self->note($self->{skip}
- ? "Hunk #$self->{hunk} ignored at 1.\n"
- : "Hunk #$self->{hunk} failed--$@");
-
- OLD:
- $which_search =
- $opts{"t"} ? 'title' :
- $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title';
-
- NEW:
- $which_search =
- $opts{"t"} ? 'title'
- : $opts{"s"} ? 'subject'
- : $opts{"a"} ? 'author'
- : 'title';
-
- You can use -wba=':' to recover the previous default which placed ':'
- at the end of a line. Thanks to Michael Cartmell for helpful
- discussions and examples.
-
- -Tokenizer updated to do syntax checking for matched ?/: pairs. Also,
- the tokenizer now outputs a unique serial number for every balanced
- pair of brace types and ?/: pairs. This greatly simplifies the
- formatter.
-
- -Long lines with repeated 'and', 'or', '&&', '||' will now have
- one such item per line. For example:
-
- OLD:
- if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x
- || ( -e $archive && $opt_r ) )
- {
- ( $pAr, $pNames ) = readAr($archive);
- }
-
- NEW:
- if ( $opt_d
- || $opt_m
- || $opt_p
- || $opt_t
- || $opt_x
- || ( -e $archive && $opt_r ) )
- {
- ( $pAr, $pNames ) = readAr($archive);
- }
-
- OLD:
- if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x
- && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y )
-
- NEW:
- if ( $vp->{X0} + 4 <= $x
- && $vp->{X0} + $vp->{W} - 4 >= $x
- && $vp->{Y0} + 4 <= $y
- && $vp->{Y0} + $vp->{H} - 4 >= $y )
-
- -Long lines with multiple concatenated tokens will have concatenated
- terms (see below) placed one per line, except for short items. For
- example:
-
- OLD:
- $report .=
- "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:"
- . $ib->crc . ": " . $ib->model() . "\n";
-
- NEW:
- $report .= "Device type:"
- . $ib->family . " ID:"
- . $ib->serial . " CRC:"
- . $ib->model()
- . $ib->crc . ": " . "\n";
-
- NOTE: at present 'short' means 8 characters or less. There is a
- tentative flag to change this (-scl), but it is undocumented and
- is likely to be changed or removed later, so only use it for testing.
- In the above example, the tokens " ID:", " CRC:", and "\n" are below
- this limit.
-
- -If a line which is short enough to fit on a single line was
- nevertheless broken in the input file at a 'good' location (see below),
- perltidy will try to retain a break. For example, the following line
- will be formatted as:
-
- open SUM, "<$file"
- or die "Cannot open $file ($!)";
-
- if it was broken in the input file, and like this if not:
-
- open SUM, "<$file" or die "Cannot open $file ($!)";
-
- GOOD: 'good' location means before 'and','or','if','unless','&&','||'
-
- The reason perltidy does not just always break at these points is that if
- there are multiple, similar statements, this would preclude alignment. So
- rather than check for this, perltidy just tries to follow the input style,
- in the hopes that the author made a good choice. Here is an example where
- we might not want to break before each 'if':
-
- ($Locale, @Locale) = ($English, @English) if (@English > @Locale);
- ($Locale, @Locale) = ($German, @German) if (@German > @Locale);
- ($Locale, @Locale) = ($French, @French) if (@French > @Locale);
- ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale);
-
- -Added wildcard file expansion for systems with shells which lack this.
- Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers
- for suggesting this. This uses builtin glob() for now; I may change that.
-
- -Added new flag -sbl which, if specified, overrides the value of -bl
- for opening sub braces. This allows formatting of this type:
-
- perltidy -sbl
-
- sub foo
- {
- if (!defined($_[0])) {
- print("Hello, World\n");
- }
- else {
- print($_[0], "\n");
- }
- }
- Requested by Don Alexander.
-
- -Fixed minor parsing error which prevented a space after a $$ variable
- (pid) in some cases. Thanks to Michael Cartmell for noting this.
- For example,
- old: $$< 700
- new: $$ < 700
-
- -Improved line break choices 'and' and 'or' to display logic better.
- For example:
-
- OLD:
- exists $self->{'build_dir'} and push @e,
- "Unwrapped into directory $self->{'build_dir'}";
-
- NEW:
- exists $self->{'build_dir'}
- and push @e, "Unwrapped into directory $self->{'build_dir'}";
-
- -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains
- abbreviation for delete-side-comments; -dsm is new abbreviation for
- delete-semicolons.
-
- -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for
- noting an error.
-
- -The default for Windows is, for now, not to do a 'perl -c' syntax
- check (but -syn will activate it). This is because of problems with
- command.com. James Freeman sent me a patch which tries to get around
- the problems, and it works in many cases, but testing revealed several
- issues that still need to be resolved. So for now, the default is no
- syntax check for Windows.
-
- -I added a -T flag when doing perl -c syntax check.
- This is because I test it on a large number of scripts from sources
- unknown, and who knows what might be hidden in initialization blocks?
- Also, deactivated the syntax check if perltidy is run as root. As a
- benign example, running the previous version of perltidy on the
- following file would cause it to disappear:
-
- BEGIN{
- print "Bye, bye baby!\n";
- unlink $0;
- }
-
- The new version will not let that happen.
-
- -I am contemplating (but have not yet implemented) making '-lp' the
- default indentation, because it is stable now and may be closer to how
- perl is commonly formatted. This could be in the next release. The
- reason that '-lp' was not the original default is that the coding for
- it was complex and not ready for the initial release of perltidy. If
- anyone has any strong feelings about this, I'd like to hear. The
- current default could always be recovered with the '-nlp' flag. </code></pre>
-
-<h2 id="pod2001-09-03">2001 09 03</h2>
-
-<pre><code> -html updates:
- - sub definition names are now specially colored, red by default.
- The letter 'm' is used to identify them.
- - keyword 'sub' now has color of other keywords.
- - restored html keyword color to __END__ and __DATA__, which was
- accidentally removed in the previous version.
-
- -A new -se (--standard-error-output) flag has been implemented and
- documented which causes all errors to be written to standard output
- instead of a .ERR file.
-
- -A new -w (--warning-output) flag has been implemented and documented
- which causes perltidy to output certain non-critical messages to the
- error output file, .ERR. These include complaints about pod usage,
- for example. The default is to not include these.
-
- NOTE: This replaces an undocumented -w=0 or --warning-level flag
- which was tentatively introduced in the previous version to avoid some
- unwanted messages. The new default is the same as the old -w=0, so
- that is no longer needed.
-
- -Improved syntax checking and corrected tokenization of functions such
- as rand, srand, sqrt, ... These can accept either an operator or a term
- to their right. This has been corrected.
-
- -Corrected tokenization of semicolon: testing of the previous update showed
- that the semicolon in the following statement was being mis-tokenized. That
- did no harm, other than adding an extra blank space, but has been corrected.
-
- for (sort {strcoll($a,$b);} keys %investments) {
- ...
- }
-
- -New syntax check: after wasting 5 minutes trying to resolve a syntax
- error in which I had an extra terminal ';' in a complex for (;;) statement,
- I spent a few more minutes adding a check for this in perltidy so it won't
- happen again.
-
- -The behavior of --break-before-subs (-bbs) and --break-before-blocks
- (-bbb) has been modified. Also, a new control parameter,
- --long-block-line-count=n (-lbl=n) has been introduced to give more
- control on -bbb. This was previously a hardwired value. The reason
- for the change is to reduce the number of unwanted blank lines that
- perltidy introduces, and make it less erratic. It's annoying to remove
- an unwanted blank line and have perltidy put it back. The goal is to
- be able to sprinkle a few blank lines in that dense script you
- inherited from Bubba. I did a lot of experimenting with different
- schemes for introducing blank lines before and after code blocks, and
- decided that there is no really good way to do it. But I think the new
- scheme is an improvement. You can always deactivate this with -nbbb.
- I've been meaning to work on this; thanks to Erik Thaysen for bringing
- it to my attention.
-
- -The .LOG file is seldom needed, and I get tired of deleting them, so
- they will now only be automatically saved if perltidy thinks that it
- made an error, which is almost never. You can still force the logfile
- to be saved with -log or -g.
-
- -Improved method for computing number of columns in a table. The old
- method always tried for an even number. The new method allows odd
- numbers when it is obvious that a list is not a hash initialization
- list.
-
- old: my (
- $name, $xsargs, $parobjs, $optypes,
- $hasp2child, $pmcode, $hdrcode, $inplacecode,
- $globalnew, $callcopy
- )
- = @_;
-
- new: my (
- $name, $xsargs, $parobjs, $optypes, $hasp2child,
- $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy
- )
- = @_;
-
- -I fiddled with the list threshold adjustment, and some small lists
- look better now. Here is the change for one of the lists in test file
- 'sparse.t':
- old:
- %units =
- ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%",
- "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%");
-
- new:
- %units = (
- "in", "in", "pt", "pt", "pc", "pi",
- "mm", "mm", "cm", "cm", "\\hsize", "%",
- "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"
- );
-
- -Improved -lp formatting at '=' sign. A break was always being added after
- the '=' sign in a statement such as this, (to be sure there was enough room
- for the parameters):
-
- old: my $fee =
- CalcReserveFee(
- $env, $borrnum,
- $biblionumber, $constraint,
- $bibitems
- );
-
- The updated version doesn't do this unless the space is really needed:
-
- new: my $fee = CalcReserveFee(
- $env, $borrnum,
- $biblionumber, $constraint,
- $bibitems
- );
-
- -I updated the tokenizer to allow $#+ and $#-, which seem to be new to
- Perl 5.6. Some experimenting with a recent version of Perl indicated
- that it allows these non-alphanumeric '$#' array maximum index
- varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#:
- seems to be valid in older versions of Perl.
-
- -Fixed a rare formatting problem with -lp (and -gnu) which caused
- excessive indentation.
-
- -Many additional syntax checks have been added.
-
- -Revised method for testing here-doc target strings; the following
- was causing trouble with a regex test because of the '*' characters:
- print <<"*EOF*";
- bla bla
- *EOF*
- Perl seems to allow almost anything to be a here doc target, so an
- exact string comparison is now used.
-
- -Made update to allow underscores in binary numbers, like '0b1100_0000'.
-
- -Corrected problem with scanning certain module names; a blank space was
- being inserted after 'warnings' in the following:
- use warnings::register;
- The problem was that warnings (and a couple of other key modules) were
- being tokenized as keywords. They should have just been identifiers.
-
- -Corrected tokenization of indirect objects after sort, system, and exec,
- after testing produced an incorrect error message for the following
- line of code:
- print sort $sortsubref @list;
-
- -Corrected minor problem where a line after a format had unwanted
- extra continuation indentation.
-
- -Delete-block-comments (and -dac) now retain any leading hash-bang line
-
- -Update for -lp (and -gnu) to not align the leading '=' of a list
- with a previous '=', since this interferes with alignment of parameters.
-
- old: my $hireDay = new Date;
- my $self = {
- firstName => undef,
- lastName => undef,
- hireDay => $hireDay
- };
-
- new: my $hireDay = new Date;
- my $self = {
- firstName => undef,
- lastName => undef,
- hireDay => $hireDay
- };
-
- -Modifications made to display tables more compactly when possible,
- without adding lines. For example,
- old:
- '1', "I", '2', "II", '3', "III", '4', "IV",
- '5', "V", '6', "VI", '7', "VII", '8', "VIII",
- '9', "IX"
- new:
- '1', "I", '2', "II", '3', "III",
- '4', "IV", '5', "V", '6', "VI",
- '7', "VII", '8', "VIII", '9', "IX"
-
- -Corrected minor bug in which -pt=2 did not keep the right paren tight
- around a '++' or '--' token, like this:
-
- for ($i = 0 ; $i < length $key ; $i++ )
-
- The formatting for this should be, and now is:
-
- for ($i = 0 ; $i < length $key ; $i++)
-
- Thanks to Erik Thaysen for noting this.
-
- -Discovered a new bug involving here-docs during testing! See BUGS.html.
-
- -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature).
- However, the attributes and prototypes must still be on the same line
- as the sub name.</code></pre>
-
-<h2 id="pod2001-07-31">2001 07 31</h2>
-
-<pre><code> -Corrected minor, uncommon bug found during routine testing, in which a
- blank got inserted between a function name and its opening paren after
- a file test operator, but only in the case that the function had not
- been previously seen. Perl uses the existence (or lack thereof) of
- the blank to guess if it is a function call. That is,
- if (-l pid_filename()) {
- became
- if (-l pid_filename ()) {
- which is a syntax error if pid_filename has not been seen by perl.
-
- -If the AutoLoader module is used, perltidy will continue formatting
- code after seeing an __END__ line. Use -nlal to deactivate this feature.
- Likewise, if the SelfLoader module is used, perltidy will continue
- formatting code after seeing a __DATA__ line. Use -nlsl to
- deactivate this feature. Thanks to Slaven Rezic for this suggestion.
-
- -pod text after __END__ and __DATA__ is now identified by perltidy
- so that -dp works correctly. Thanks to Slaven Rezic for this suggestion.
-
- -The first $VERSION line which might be eval'd by MakeMaker
- is now passed through unchanged. Use -npvl to deactivate this feature.
- Thanks to Manfred Winter for this suggestion.
-
- -Improved indentation of nested parenthesized expressions. Tests have
- given favorable results. Thanks to Wolfgang Weisselberg for helpful
- examples.</code></pre>
-
-<h2 id="pod2001-07-23">2001 07 23</h2>
-
-<pre><code> -Fixed a very rare problem in which an unwanted semicolon was inserted
- due to misidentification of anonymous hash reference curly as a code
- block curly. (No instances of this have been reported; I discovered it
- during testing). A workaround for older versions of perltidy is to use
- -nasc.
-
- -Added -icb (-indent-closing-brace) parameter to indent a brace which
- terminates a code block to the same level as the previous line.
- Suggested by Andrew Cutler. For example,
-
- if ($task) {
- yyy();
- } # -icb
- else {
- zzz();
- }
-
- -Rewrote error message triggered by an unknown bareword in a print or
- printf filehandle position, and added flag -w=0 to prevent issuing this
- error message. Suggested by Byron Jones.
-
- -Added modification to align a one-line 'if' block with similar
- following 'elsif' one-line blocks, like this:
- if ( $something eq "simple" ) { &handle_simple }
- elsif ( $something eq "hard" ) { &handle_hard }
- (Suggested by Wolfgang Weisselberg).</code></pre>
-
-<h2 id="pod2001-07-02">2001 07 02</h2>
-
-<pre><code> -Eliminated all constants with leading underscores because perl 5.005_03
- does not support that. For example, _SPACES changed to XX_SPACES.
- Thanks to kromJx for this update.</code></pre>
-
-<h2 id="pod2001-07-01">2001 07 01</h2>
-
-<pre><code> -the directory of test files has been moved to a separate distribution
- file because it is getting large but is of little interest to most users.
- For the current distribution:
- perltidy-20010701.tgz contains the source and docs for perltidy
- perltidy-20010701-test.tgz contains the test files
-
- -fixed bug where temporary file perltidy.TMPI was not being deleted
- when input was from stdin.
-
- -adjusted line break logic to not break after closing brace of an
- eval block (suggested by Boris Zentner).
-
- -added flag -gnu (--gnu-style) to give an approximation to the GNU
- style as sometimes applied to perl. The programming style in GNU
- 'automake' was used as a guide in setting the parameters; these
- parameters will probably be adjusted over time.
-
- -an empty code block now has one space for emphasis:
- if ( $cmd eq "bg_untested" ) {} # old
- if ( $cmd eq "bg_untested" ) { } # new
- If this bothers anyone, we could create a parameter.
-
- -the -bt (--brace-tightness) parameter has been split into two
- parameters to give more control. -bt now applies only to non-BLOCK
- braces, while a new parameter -bbt (block-brace-tightness) applies to
- curly braces which contain code BLOCKS. The default value is -bbt=0.
-
- -added flag -icp (--indent-closing-paren) which leaves a statement
- termination of the form );, };, or ]; indented with the same
- indentation as the previous line. For example,
-
- @month_of_year = ( # default, or -nicp
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
- 'Nov', 'Dec'
- );
-
- @month_of_year = ( # -icp
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
- 'Nov', 'Dec'
- );
-
- -Vertical alignment updated to synchronize with tokens &&, ||,
- and, or, if, unless. Allowable space before forcing
- resynchronization has been increased. (Suggested by Wolfgang
- Weisselberg).
-
- -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold,
- and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There
- was no way to negate these previously. html documentation updated and
- corrected. (Suggested by Wolfgang Weisselberg).
-
- -Some modifications have been made which improve the -lp formatting in
- a few cases.
-
- -Perltidy now retains or creates a blank line after an =cut to keep
- podchecker happy (Suggested by Manfred H. Winter). This appears to be
- a glitch in podchecker, but it was annoying.</code></pre>
-
-<h2 id="pod2001-06-17">2001 06 17</h2>
-
-<pre><code> -Added -bli flag to give continuation indentation to braces, like this
-
- if ($bli_flag)
- {
- extra_indentation();
- }
-
- -Corrected an error with the tab (-t) option which caused the last line
- of a multi-line quote to receive a leading tab. This error was in
- version 2001 06 08 but not 2001 04 06. If you formatted a script
- with -t with this version, please check it by running once with the
- -chk flag and perltidy will scan for this possible error.
-
- -Corrected an invalid pattern (\R should have been just R), changed
- $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected
- several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg,
- 2001-06-12, for catching these errors.
-
- -A '-bar' flag has been added to require braces to always be on the
- right, even for multi-line if and foreach statements. For example,
- the default formatting of a long if statement would be:
-
- if ($bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4)
- {
- bigwastoftime();
- }
-
- With -bar, the formatting is:
-
- if ($bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4) {
- bigwastoftime();
- }
- Suggested by Eli Fidler 2001-06-11.
-
- -Uploaded perltidy to sourceforge cvs 2001-06-10.
-
- -An '-lp' flag (--line-up-parentheses) has been added which causes lists
- to be indented with extra indentation in the manner sometimes
- associated with emacs or the GNU suggestions. Thanks to Ian Stuart for
- this suggestion and for extensive help in testing it.
-
- -Subroutine call parameter lists are now formatted as other lists.
- This should improve formatting of tables being passed via subroutine
- calls. This will also cause full indentation ('-i=n, default n= 4) of
- continued parameter list lines rather than just the number of spaces
- given with -ci=n, default n=2.
-
- -Added support for hanging side comments. Perltidy identifies a hanging
- side comment as a comment immediately following a line with a side
- comment or another hanging side comment. This should work in most
- cases. It can be deactivated with --no-hanging-side-comments (-nhsc).
- The manual has been updated to discuss this. Suggested by Brad
- Eisenberg some time ago, and finally implemented.</code></pre>
-
-<h2 id="pod2001-06-08">2001 06 08</h2>
-
-<pre><code> -fixed problem with parsing command parameters containing quoted
- strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07).
-
- -added two command line flags, --want-break-after and
- --want-break-before, which allow changing whether perltidy
- breaks lines before or after any operators. Please see the revised
- man pages for details.
-
- -added system-wide configuration file capability.
- If perltidy does not find a .perltidyrc command line file in
- the current directory, nor in the home directory, it now looks
- for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'.
- (Suggested by Roger Espel Llima 2001-05-31).
-
- -fixed problem in which spaces were trimmed from lines of a multi-line
- quote. (Reported by Roger Espel Llima 2001-05-30). This is an
- uncommon situation, but serious, because it could conceivably change
- the proper function of a script.
-
- -fixed problem in which a semicolon was incorrectly added within
- an anonymous hash. (Reported by A.C. Yardley, 2001-5-23).
- (You would know if this happened, because perl would give a syntax
- error for the resulting script).
-
- -fixed problem in which an incorrect error message was produced
- after a version number on a 'use' line, like this ( Reported
- by Andres Kroonmaa, 2001-5-14):
-
- use CGI 2.42 qw(fatalsToBrowser);
-
- Other than the extraneous error message, this bug was harmless.</code></pre>
-
-<h2 id="pod2001-04-06">2001 04 06</h2>
-
-<pre><code> -fixed serious bug in which the last line of some multi-line quotes or
- patterns was given continuation indentation spaces. This may make
- a pattern incorrect unless it uses the /x modifier. To find
- instances of this error in scripts which have been formatted with
- earlier versions of perltidy, run with the -chk flag, which has
- been added for this purpose (SLH, 2001-04-05).
-
- ** So, please check previously formatted scripts by running with -chk
- at least once **
-
- -continuation indentation has been reprogrammed to be hierarchical,
- which improves deeply nested structures.
-
- -fixed problem with undefined value in list formatting (reported by Michael
- Langner 2001-04-05)
-
- -Switched to graphical display of nesting in .LOG files. If an
- old format string was "(1 [0 {2", the new string is "{{(". This
- is easier to read and also shows the order of nesting.
-
- -added outdenting of cuddled paren structures, like ")->pack(".
-
- -added line break and outdenting of ')->' so that instead of
-
- $mw->Label(
- -text => "perltidy",
- -relief => 'ridge')->pack;
-
- the current default is:
-
- $mw->Label(
- -text => "perltidy",
- -relief => 'ridge'
- )->pack;
-
- (requested by Michael Langner 2001-03-31; in the future this could
- be controlled by a command-line parameter).
-
- -revised list indentation logic, so that lists following an assignment
- operator get one full indentation level, rather than just continuation
- indentation. Also corrected some minor glitches in the continuation
- indentation logic.
-
- -Fixed problem with unwanted continuation indentation after a blank line
- (reported by Erik Thaysen 2001-03-28):
-
- -minor update to avoid stranding a single '(' on one line</code></pre>
-
-<h2 id="pod2001-03-28">2001 03 28:</h2>
-
-<pre><code> -corrected serious error tokenizing filehandles, in which a sub call
- after a print or printf, like this:
- print usage() and exit;
- became this:
- print usage () and exit;
- Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun
- perltidy; it will look for this situation and issue a warning.
-
- -fixed another cuddled-else formatting bug (Reported by Craig Bourne)
-
- -added several diagnostic --dump routines
-
- -added token-level whitespace controls (suggested by Hans Ecke)</code></pre>
-
-<h2 id="pod2001-03-23">2001 03 23:</h2>
-
-<pre><code> -added support for special variables of the form ${^WANT_BITS}
-
- -space added between scalar and left paren in 'for' and 'foreach' loops,
- (suggestion by Michael Cartmell):
-
- for $i( 1 .. 20 ) # old
- for $i ( 1 .. 20 ) # new
-
- -html now outputs cascading style sheets (thanks to suggestion from
- Hans Ecke)
-
- -flags -o and -st now work with -html
-
- -added missing -html documentation for comments (noted by Alex Izvorski)
-
- -support for VMS added (thanks to Michael Cartmell for code patches and
- testing)
-
- -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive
- testing by Michael Cartmell)
-
- -fixed problem where operand may be empty at line 3970
- (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen,
- Keith Marshall for bug reports)
-
- -fixed -ce bug (cuddled else), where lines like '} else {' were indented
- (Thanks to Shawn Stepper and Rick Measham for reporting this)</code></pre>
-
-<h2 id="pod2001-03-04">2001 03 04:</h2>
-
-<pre><code> -fixed undefined value in line 153 (only worked with -I set)
- (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others)
-
- -fixed undefined value in line 1069 (filehandle problem with perl versions <
- 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber)</code></pre>
-
-<h2 id="pod2001-03-03">2001 03 03:</h2>
-
-<pre><code> -Initial announcement at freshmeat.net; started Change Log
- (Unfortunately this version was DOA, but it was fixed the next day)</code></pre>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# Perltidy Change Log
+
+## 2018 11 16
+
+ - Fixed RT #126965, in which a ternary operator was misparsed if immediately
+ following a function call without arguments, such as:
+ my $restrict_customer = shift ? 1 : 0;
+
+ - Fixed RT #125012: bug in -mangle --delete-all-comments
+ A needed blank space bareword tokens was being removed when comments were
+ deleted
+
+ - Fixed RT #81852: Stacked containers and quoting operators. Quoted words
+ (qw) delimited by container tokens ('{', '[', '(', '<') are now included in
+ the --weld-nested (-wn) flag:
+
+ # perltidy -wn
+ use_all_ok( qw{
+ PPI
+ PPI::Tokenizer
+ PPI::Lexer
+ PPI::Dumper
+ PPI::Find
+ PPI::Normal
+ PPI::Util
+ PPI::Cache
+ } );
+
+ - The cuddled-else (-ce) coding was merged with the new cuddled-block (-cb)
+ coding. The change is backward compatible and simplifies input.
+ The --cuddled-block-option=n (-cbo=n) flag now applies to both -ce and -cb
+ formatting. In fact the -cb flag is just an alias for -ce now.
+
+ - Fixed RT #124594, license text desc. changed from 'GPL-2.0+' to 'gpl_2'
+
+ - Fixed bug in which a warning about a possible code bug was issued in a
+ script with brace errors.
+
+ - added option --notimestamp or -nts to eliminate any time stamps in output
+ files. This is used to prevent differences in test scripts from causing
+ failure at installation. For example, the -cscw option will put a date
+ stamp on certain closing side comments. We need to avoid this in order
+ to test this feature in an installation test.
+
+ - Fixed bug with the entab option, -et=8, in which the leading space of
+ some lines was was not entabbed. This happened in code which was adjusted
+ for vertical alignment and in hanging side comments. Thanks to Glenn.
+
+ - Fixed RT #127633, undesirable line break after return when -baao flag is set
+
+ - Fixed RT #127035, vertical alignment. Vertical alignment has been improved
+ in several ways. Thanks especially to Glenn and Michael Wardman for sending
+ helpful snippets.
+
+ - In many cases, two lines which were previously left unaligned are now
+ aligned.
+
+ OLD:
+ $expect = "1$expect" if $expect =~ /^e/i;
+ $p = "1$p" if defined $p and $p =~ /^e/i;
+
+ NEW:
+ $expect = "1$expect" if $expect =~ /^e/i;
+ $p = "1$p" if defined $p and $p =~ /^e/i;
+
+ - Alignment of the =~ operators has been reactivated.
+
+ OLD:
+ $service_profile =~ s/^\s+|\s+$//g;
+ $host_profile =~ s/^\s+|\s+$//g;
+
+ NEW:
+ $service_profile =~ s/^\s+|\s+$//g;
+ $host_profile =~ s/^\s+|\s+$//g;
+
+ - Alignment of the // operator has been reactivated.
+
+ OLD:
+ is( pop // 7, 7, 'pop // ... works' );
+ is( pop() // 7, 0, 'pop() // ... works' );
+ is( pop @ARGV // 7, 3, 'pop @array // ... works' );
+
+ NEW:
+ is( pop // 7, 7, 'pop // ... works' );
+ is( pop() // 7, 0, 'pop() // ... works' );
+ is( pop @ARGV // 7, 3, 'pop @array // ... works' );
+
+ - RT #106493; source code repository location has been added to docs; it is
+ https://github.com/perltidy/perltidy
+
+ - The packaging for this version has changed. The Tidy.pm module is much
+ smaller. Supporting modules have been split out from it and placed below
+ it in the path Perl/Tidy/*.
+
+ - A number of new installation test cases have been added. Updates are now
+ continuously tested at Travis CI against versions back to Perl 5.08.
+
+## 2018 02 20
+
+ - RT #124469, #124494, perltidy often making empty files. The previous had
+ an index error causing it to fail, particularly in version 5.18 of Perl.
+
+ Please avoid version 20180219.
+
+## 2018 02 19
+
+ - RT #79947, cuddled-else generalization. A new flag -cb provides
+ 'cuddled-else' type formatting for an arbitrary type of block chain. The
+ default is try-catch-finally, but this can be modified with the
+ parameter -cbl.
+
+ - Fixed RT #124298: add space after ! operator without breaking !! secret
+ operator
+
+ - RT #123749: numerous minor improvements to the -wn flag were made.
+
+ - Fixed a problem with convergence tests in which iterations were stopping
+ prematurely.
+
+ - Here doc targets for <<~ type here-docs may now have leading whitespace.
+
+ - Fixed RT #124354. The '-indent-only' flag was not working correctly in the
+ previous release. A bug in version 20180101 caused extra blank lines
+ to be output.
+
+ - Issue RT #124114. Some improvements were made in vertical alignment
+ involving 'fat commas'.
+
+## 2018 01 01
+
+ - Added new flag -wn (--weld-nested-containers) which addresses these issues:
+ RT #123749: Problem with promises;
+ RT #119970: opening token stacking strange behavior;
+ RT #81853: Can't stack block braces
+
+ This option causes closely nested pairs of opening and closing containers
+ to be "welded" together and essentially be formatted as a single unit,
+ with just one level of indentation.
+
+ Since this is a new flag it is set to be "off" by default but it has given
+ excellent results in testing.
+
+ EXAMPLE 1, multiple blocks, default formatting:
+ do {
+ {
+ next if $x == $y; # do something here
+ }
+ } until $x++ > $z;
+
+ perltidy -wn
+ do { {
+ next if $x == $y;
+ } } until $x++ > $z;
+
+ EXAMPLE 2, three levels of wrapped function calls, default formatting:
+ p(
+ em(
+ conjug(
+ translate( param('verb') ), param('tense'),
+ param('person')
+ )
+ )
+ );
+
+ # perltidy -wn
+ p( em( conjug(
+ translate( param('verb') ),
+ param('tense'), param('person')
+ ) ) );
+
+ # EXAMPLE 3, chained method calls, default formatting:
+ get('http://mojolicious.org')->then(
+ sub {
+ my $mojo = shift;
+ say $mojo->res->code;
+ return get('http://metacpan.org');
+ }
+ )->then(
+ sub {
+ my $cpan = shift;
+ say $cpan->res->code;
+ }
+ )->catch(
+ sub {
+ my $err = shift;
+ warn "Something went wrong: $err";
+ }
+ )->wait;
+
+ # perltidy -wn
+ get('http://mojolicious.org')->then( sub {
+ my $mojo = shift;
+ say $mojo->res->code;
+ return get('http://metacpan.org');
+ } )->then( sub {
+ my $cpan = shift;
+ say $cpan->res->code;
+ } )->catch( sub {
+ my $err = shift;
+ warn "Something went wrong: $err";
+ } )->wait;
+
+
+ - Fixed RT #114359: Missparsing of "print $x ** 0.5;
+
+ - Deactivated the --check-syntax flag for better security. It will be
+ ignored if set.
+
+ - Corrected minimum perl version from 5.004 to 5.008 based on perlver
+ report. The change is required for coding involving wide characters.
+
+ - For certain severe errors, the source file will be copied directly to the
+ output without formatting. These include ending in a quote, ending in a
+ here doc, and encountering an unidentified character.
+
+## 2017 12 14
+
+ - RT #123749, partial fix. "Continuation indentation" is removed from lines
+ with leading closing parens which are part of a call chain.
+ For example, the call to pack() is is now outdented to the starting
+ indentation in the following experession:
+
+ # OLD
+ $mw->Button(
+ -text => "New Document",
+ -command => \&new_document
+ )->pack(
+ -side => 'bottom',
+ -anchor => 'e'
+ );
+
+ # NEW
+ $mw->Button(
+ -text => "New Document",
+ -command => \&new_document
+ )->pack(
+ -side => 'bottom',
+ -anchor => 'e'
+ );
+
+ This modification improves readability of complex expressions, especially
+ when the user uses the same value for continuation indentation (-ci=n) and
+ normal indentation (-i=n). Perltidy was already programmed to
+ do this but a minor bug was preventing it.
+
+ - RT #123774, added flag to control space between a backslash and a single or
+ double quote, requested by Robert Rothenberg. The issue is that lines like
+
+ $str1=\"string1";
+ $str2=\'string2';
+
+ confuse syntax highlighters unless a space is left between the backslash and
+ the quote.
+
+ The new flag to control this is -sbq=n (--space-backslash-quote=n),
+ where n=0 means no space, n=1 means follow existing code, n=2 means always
+ space. The default is n=1, meaning that a space will be retained if there
+ is one in the source code.
+
+ - Fixed RT #123492, support added for indented here doc operator <<~ added
+ in v5.26. Thanks to Chris Weyl for the report.
+
+ - Fixed docs; --closing-side-comment-list-string should have been just
+ --closing-side-comment-list. Thanks to F.Li.
+
+ - Added patch RT #122030] Perl::Tidy sometimes does not call binmode.
+ Thanks to Irilis Aelae.
+
+ - Fixed RT #121959, PERLTIDY doesn't honor the 'three dot' notation for
+ locating a config file using environment variables. Thanks to John
+ Wittkowski.
+
+ - Minor improvements to formatting, in which some additional vertical
+ aligmnemt is done. Thanks to Keith Neargarder.
+
+ - RT #119588. Vertical alignment is no longer done for // operator.
+
+## 2017 05 21
+
+ - Fixed debian #862667: failure to check for perltidy.ERR deletion can lead
+ to overwriting abritrary files by symlink attack. Perltidy was continuing
+ to write files after an unlink failure. Thanks to Don Armstrong
+ for a patch.
+
+ - Fixed RT #116344, perltidy fails on certain anonymous hash references:
+ in the following code snippet the '?' was misparsed as a pattern
+ delimiter rather than a ternary operator.
+ return ref {} ? 1 : 0;
+
+ - Fixed RT #113792: misparsing of a fat comma (=>) right after
+ the __END__ or __DATA__ tokens. These keywords were getting
+ incorrectly quoted by the following => operator.
+
+ - Fixed RT #118558. Custom Getopt::Long configuration breaks parsing
+ of perltidyrc. Perltidy was resetting the users configuration too soon.
+
+ - Fixed RT #119140, failure to parse double diamond operator. Code to
+ handle this new operator has been added.
+
+ - Fixed RT #120968. Fixed problem where -enc=utf8 didn't work
+ with --backup-and-modify-in-place. Thanks to Heinz Knutzen for this patch.
+
+ - Fixed minor formatting issue where one-line blocks for subs with signatures
+ were unnecesarily broken
+
+ - RT #32905, patch to fix utf-8 error when output was STDOUT.
+
+ - RT #79947, improved spacing of try/catch/finally blocks. Thanks to qsimpleq
+ for a patch.
+
+ - Fixed #114909, Anonymous subs with signatures and prototypes misparsed as
+ broken ternaries, in which a statement such as this was not being parsed
+ correctly:
+ return sub ( $fh, $out ) : prototype(*$) { ... }
+
+ - Implemented RT #113689, option to introduces spaces after an opening block
+ brace and before a closing block brace. Four new optional controls are
+ added. The first two define the minimum number of blank lines to be
+ inserted
+
+ -blao=i or --blank-lines-after-opening-block=i
+ -blbc=i or --blank-lines-before-closing-block=i
+
+ where i is an integer, the number of lines (the default is 0).
+
+ The second two define the types of blocks to which the first two apply
+
+ -blaol=s or --blank-lines-after-opening-block-list=s
+ -blbcl=s or --blank-lines-before-closing-block-list=s
+
+ where s is a string of possible block keywords (default is just 'sub',
+ meaning a named subroutine).
+
+ For more information please see the documentation.
+
+ - The method for specifying block types for certain input parameters has
+ been generalized to distinguish between normal named subroutines and
+ anonymous subs. The keyword for normal subroutines remains 'sub', and
+ the new keyword for anonymous subs is 'asub'.
+
+ - Minor documentation changes. The BUGS sections now have a link
+ to CPAN where most open bugs and issues can be reviewed and bug reports
+ can be submitted. The information in the AUTHOR and CREDITS sections of
+ the man pages have been removed from the man pages to streamline the
+ documentation. This information is still in the source code.
+
+## 2016 03 02
+
+ - RT #112534. Corrected a minor problem in which an unwanted newline
+ was placed before the closing brace of an anonymous sub with
+ a signature, if it was in a list. Thanks to Dmytro Zagashev.
+
+ - Corrected a minor problem in which occasional extra indentation was
+ given to the closing brace of an anonymous sub in a list when the -lp
+ parameter was set.
+
+## 2016 03 01
+
+ - RT #104427. Added support for signatures.
+
+ - RT #111512. Changed global warning flag $^W = 1 to use warnings;
+ Thanks to Dmytro Zagashev.
+
+ - RT #110297, added support for new regexp modifier /n
+ Thanks to Dmytro Zagashev.
+
+ - RT #111519. The -io (--indent-only) and -dac (--delete-all-comments)
+ can now both be used in one pass. Thanks to Dmitry Veltishev.
+
+ - Patch to avoid error message with 'catch' used by TryCatch, as in
+ catch($err){
+ # do something
+ }
+ Thanks to Nick Tonkin.
+
+ - RT #32905, UTF-8 coding is now more robust. Thanks to qsimpleq
+ and Dmytro for patches.
+
+ - RT #106885. Added string bitwise operators ^. &. |. ~. ^.= &.= |.=
+
+ - Fixed RT #107832 and #106492, lack of vertical alignment of two lines
+ when -boc flag (break at old commas) is set. This bug was
+ inadvertantly introduced in previous bug fix RT #98902.
+
+ - Some common extensions to Perl syntax are handled better.
+ In particular, the following snippet is now foratted cleanly:
+
+ method deposit( Num $amount) {
+ $self->balance( $self->balance + $amount );
+ }
+
+ A new flag -xs (--extended-syntax) was added to enable this, and the default
+ is to use -xs.
+
+ In previous versions, and now only when -nxs is set, this snippet of code
+ generates the following error message:
+
+ "syntax error at ') {', didn't see one of: case elsif for foreach given if switch unless until when while"
+
+## 2015 08 15
+
+ - Fixed RT# 105484, Invalid warning about 'else' in 'switch' statement. The
+ warning happened if a 'case' statement did not use parens.
+
+ - Fixed RT# 101547, misparse of // caused error message. Also..
+
+ - Fixed RT# 102371, misparse of // caused unwated space in //=
+
+ - Fixed RT# 100871, "silent failure of HTML Output on Windows".
+ Changed calls to tempfile() from:
+ my ( $fh_tmp, $tmpfile ) = tempfile();
+ to have the full path name:
+ my ( $fh_tmp, $tmpfile ) = File::Temp::tempfile()
+ because of problems in the Windows version reported by Dean Pearce.
+
+ - Fixed RT# 99514, calling the perltidy module multiple times with
+ a .perltidyrc file containing the parameter --output-line-ending
+ caused a crash. This was a glitch in the memoization logic.
+
+ - Fixed RT#99961, multiple lines inside a cast block caused unwanted
+ continuation indentation.
+
+ - RT# 32905, broken handling of UTF-8 strings.
+ A new flag -utf8 causes perltidy assume UTF-8 encoding for input and
+ output of an io stream. Thanks to Sebastian Podjasek for a patch.
+ This feature may not work correctly in older versions of Perl.
+ It worked in a linux version 5.10.1 but not in a Windows version 5.8.3 (but
+ otherwise perltidy ran correctly).
+
+ - Warning files now report perltidy VERSION. Suggested by John Karr.
+
+ - Fixed long flag --nostack-closing-tokens (-nsct has always worked though).
+ This was due to a typo. This also fixed --nostack-opening-tokens to
+ behave correctly. Thanks to Rob Dixon.
+
+## 2014 07 11
+
+ - Fixed RT #94902: abbreviation parsing in .perltidyrc files was not
+ working for multi-line abbreviations. Thanks to Eric Fung for
+ supplying a patch.
+
+ - Fixed RT #95708, misparsing of a hash when the first key was a perl
+ keyword, causing a semicolon to be incorrectly added.
+
+ - Fixed RT #94338 for-loop in a parenthesized block-map. A code block within
+ parentheses of a map, sort, or grep function was being mistokenized. In
+ rare cases this could produce in an incorrect error message. The fix will
+ produce some minor formatting changes. Thanks to Daniel Trizen
+ discovering and documenting this.
+
+ - Fixed RT #94354, excess indentation for stacked tokens. Thanks to
+ Colin Williams for supplying a patch.
+
+ - Added support for experimental postfix dereferencing notation introduced in
+ perl 5.20. RT #96021.
+
+ - Updated documentation to clarify the behavior of the -io flag
+ in response to RT #95709. You can add -noll or -l=0 to prevent
+ long comments from being outdented when -io is used.
+
+ - Added a check to prevent a problem reported in RT #81866, where large
+ scripts which had been compressed to a single line could not be formatted
+ because of a check for VERSION for MakeMaker. The workaround was to
+ use -nvpl, but this shouldn't be necessary now.
+
+ - Fixed RT #96101; Closing brace of anonymous sub in a list was being
+ indented. For example, the closing brace of the anonymous sub below
+ will now be lined up with the word 'callback'. This problem
+ occured if there was no comma after the closing brace of the anonymous sub.
+ This update may cause minor changes to formatting of code with lists
+ of anonymous subs, especially TK code.
+
+ # OLD
+ my @menu_items = (
+
+ #...
+ {
+ path => '/_Operate/Transcode and split',
+ callback => sub {
+ return 1 if not $self->project_opened;
+ $self->comp('project')->transcode( split => 1 );
+ }
+ }
+ );
+
+ # NEW
+ my @menu_items = (
+
+ #...
+ {
+ path => '/_Operate/Transcode and split',
+ callback => sub {
+ return 1 if not $self->project_opened;
+ $self->comp('project')->transcode( split => 1 );
+ }
+ }
+ );
+
+## 2014 03 28
+
+ - Fixed RT #94190 and debian Bug #742004: perltidy.LOG file left behind.
+ Thanks to George Hartzell for debugging this. The problem was
+ caused by the memoization speedup patch in version 20121207. An
+ unwanted flag was being set which caused a LOG to be written if
+ perltidy was called multiple times.
+
+ - New default behavior for LOG files: If the source is from an array or
+ string (through a call to the perltidy module) then a LOG output is only
+ possible if a logfile stream is specified. This is to prevent
+ unexpected perltidy.LOG files.
+
+ - Fixed debian Bug #740670, insecure temporary file usage. File::Temp is now
+ used to get a temporary file. Thanks to Don Anderson for a patch.
+
+ - Any -b (--backup-and-modify-in-place) flag is silently ignored when a
+ source stream, destination stream, or standard output is used.
+ This is because the -b flag may have been in a .perltidyrc file and
+ warnings break Test::NoWarnings. Thanks to Marijn Brand.
+
+## 2013 09 22
+
+ - Fixed RT #88020. --converge was not working with wide characters.
+
+ - Fixed RT #78156. package NAMESPACE VERSION syntax not accepted.
+
+ - First attempt to fix RT #88588. INDEX END tag change in pod2html breaks
+ perltidy -html. I put in a patch which should work but I don't yet have
+ a way of testing it.
+
+## 2013 08 06
+
+ - Fixed RT #87107, spelling
+
+## 2013 08 05
+
+ - Fixed RT #87502, incorrect of parsing of smartmatch before hash brace
+
+ - Added feature request RT #87330, trim whitespace after POD.
+ The flag -trp (--trim-pod) will trim trailing whitespace from lines of POD
+
+## 2013 07 17
+
+ - Fixed RT #86929, #86930, missing lhs of assignment.
+
+ - Fixed RT #84922, moved pod from Tidy.pm into Tidy.pod
+
+## 2012 12 07
+
+ - The flag -cab=n or --comma-arrow-breakpoints=n has been generalized
+ to give better control over breaking open short containers. The
+ possible values are now:
+
+ n=0 break at all commas after =>
+ n=1 stable: break at all commas after => if container is open,
+ EXCEPT FOR one-line containers
+ n=2 break at all commas after =>, BUT try to form the maximum
+ maximum one-line container lengths
+ n=3 do not treat commas after => specially at all
+ n=4 break everything: like n=0 but also break a short container with
+ a => not followed by a comma
+ n=5 stable: like n=1 but ALSO break at open one-line containers (default)
+
+ New values n=4 and n=5 have been added to allow short blocks to be
+ broken open. The new default is n=5, stable. It should more closely
+ follow the breaks in the input file, and previously formatted code
+ should remain unchanged. If this causes problems use -cab=1 to recover
+ the former behavior. Thanks to Tony Maszeroski for the suggestion.
+
+ To illustrate the need for the new options, if perltidy is given
+ the following code, then the old default (-cab=1) was to close up
+ the 'index' container even if it was open in the source. The new
+ default (-cab=5) will keep it open if it was open in the source.
+
+ our $fancypkg = {
+ 'ALL' => {
+ 'index' => {
+ 'key' => 'value',
+ },
+ 'alpine' => {
+ 'one' => '+',
+ 'two' => '+',
+ 'three' => '+',
+ },
+ }
+ };
+
+ - New debug flag --memoize (-mem). This version contains a
+ patch supplied by Jonathan Swartz which can significantly speed up
+ repeated calls to Perl::Tidy::perltidy in a single process by caching
+ the result of parsing the formatting parameters. A factor of up to 10
+ speedup was achieved for masontidy (https://metacpan.org/module/masontidy).
+ The memoization patch is on by default but can be deactivated for
+ testing with -nmem (or --no-memoize).
+
+ - New flag -tso (--tight-secret-operators) causes certain perl operator
+ sequences (secret operators) to be formatted "tightly" (without spaces).
+ The most common of these are 0 + and + 0 which become 0+ and +0. The
+ operators currently modified by this flag are:
+ =( )= 0+ +0 ()x!! ~~<> ,=>
+ Suggested by by Philippe Bruhat. See https://metacpan.org/module/perlsecret
+ This flag is off by default.
+
+ - New flag -vmll (--variable-maximum-line-length) makes the maximum
+ line length increase with the nesting depth of a line of code.
+ Basically, it causes the length of leading whitespace to be ignored when
+ setting line breaks, so the formatting of a block of code is independent
+ of its nesting depth. Try this option if you have deeply nested
+ code or data structures, perhaps in conjunction with the -wc flag
+ described next. The default is not todo this.
+
+ - New flag -wc=n (--whitespace-cycle=n) also addresses problems with
+ very deeply nested code and data structures. When this parameter is
+ used and the nesting depth exceeds the value n, the leading whitespace
+ will be reduced and start at 1 again. The result is that deeply
+ nested blocks of code will shift back to the left. This occurs cyclically
+ to any nesting depth. This flag may be used either with or without -vmll.
+ The default is not to use this (-wc=0).
+
+ - Fixed RT #78764, error parsing smartmatch operator followed by anonymous
+ hash or array and then a ternary operator; two examples:
+
+ qr/3/ ~~ ['1234'] ? 1 : 0;
+ map { $_ ~~ [ '0', '1' ] ? 'x' : 'o' } @a;
+
+ - Fixed problem with specifying spaces around arrows using -wls='->'
+ and -wrs='->'. Thanks to Alain Valleton for documenting this problem.
+
+ - Implemented RT #53183, wishlist, lines of code with the same indentation
+ level which are contained with multiple stacked opening and closing tokens
+ (requested with flags -sot -sct) now have reduced indentation.
+
+ # Default
+ $sender->MailMsg(
+ {
+ to => $addr,
+ subject => $subject,
+ msg => $body
+ }
+ );
+
+ # OLD: perltidy -sot -sct
+ $sender->MailMsg( {
+ to => $addr,
+ subject => $subject,
+ msg => $body
+ } );
+
+ # NEW: perltidy -sot -sct
+ $sender->MailMsg( {
+ to => $addr,
+ subject => $subject,
+ msg => $body
+ } );
+
+ - New flag -act=n (--all-containers-tightness=n) is an abbreviation for
+ -pt=n -sbt=n -bt=n -bbt=n, where n=0,1, or 2. It simplifies input when all
+ containers have the same tightness. Using the same example:
+
+ # NEW: perltidy -sot -sct -act=2
+ $sender->MailMsg({
+ to => $addr,
+ subject => $subject,
+ msg => $body
+ });
+
+ - New flag -sac (--stack-all-containers) is an abbreviation for -sot -sct
+ This is part of wishlist item RT #53183. Using the same example again:
+
+ # NEW: perltidy -sac -act=2
+ $sender->MailMsg({
+ to => $addr,
+ subject => $subject,
+ msg => $body
+ });
+
+ - new flag -scbb (--stack-closing-block-brace) causes isolated closing
+ block braces to stack as in the following example. (Wishlist item RT#73788)
+
+ DEFAULT:
+ for $w1 (@w1) {
+ for $w2 (@w2) {
+ for $w3 (@w3) {
+ for $w4 (@w4) {
+ push( @lines, "$w1 $w2 $w3 $w4\n" );
+ }
+ }
+ }
+ }
+
+ perltidy -scbb:
+ for $w1 (@w1) {
+ for $w2 (@w2) {
+ for $w3 (@w3) {
+ for $w4 (@w4) {
+ push( @lines, "$w1 $w2 $w3 $w4\n" );
+ } } } }
+
+ There is, at present, no flag to place these closing braces at the end
+ of the previous line. It seems difficult to develop good rules for
+ doing this for a wide variety of code and data structures.
+
+ - Parameters defining block types may use a wildcard '*' to indicate
+ all block types. Previously it was not possible to include bare blocks.
+
+ - A flag -sobb (--stack-opening-block-brace) has been introduced as an
+ alias for -bbvt=2 -bbvtl='*'. So for example the following test code:
+
+ {{{{{{{ $testing }}}}}}}
+
+ cannot be formatted as above but can at least be kept vertically compact
+ using perltidy -sobb -scbb
+
+ { { { { { { { $testing
+ } } } } } } }
+
+ Or even, perltidy -sobb -scbb -i=1 -bbt=2
+ {{{{{{{$testing
+ }}}}}}}
+
+
+ - Error message improved for conflicts due to -pbp; thanks to Djun Kim.
+
+ - Fixed RT #80645, error parsing special array name '@$' when used as
+ @{$} or $#{$}
+
+ - Eliminated the -chk debug flag which was included in version 20010406 to
+ do a one-time check for a bug with multi-line quotes. It has not been
+ needed since then.
+
+ - Numerous other minor formatting improvements.
+
+## 2012 07 14
+
+ - Added flag -iscl (--ignore-side-comment-lengths) which causes perltidy
+ to ignore the length of side comments when setting line breaks,
+ RT #71848. The default is to include the length of side comments when
+ breaking lines to stay within the length prescribed by the -l=n
+ maximum line length parameter. For example,
+
+ Default behavior on a single line with long side comment:
+ $vmsfile =~ s/;[\d\-]*$//
+ ; # Clip off version number; we can use a newer version as well
+
+ perltidy -iscl leaves the line intact:
+
+ $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well
+
+ - Fixed RT #78182, side effects with STDERR. Error handling has been
+ revised and the documentation has been updated. STDERR can now be
+ redirected to a string reference, and perltidy now returns an
+ error flag instead of calling die when input errors are detected.
+ If the error flag is set then no tidied output was produced.
+ See man Perl::Tidy for an example.
+
+ - Fixed RT #78156, erroneous warning message for package VERSION syntax.
+
+ - Added abbreviations -conv (--converge) to simplify iteration control.
+ -conv is equivalent to -it=4 and will insure that the tidied code is
+ converged to its final state with the minimum number of iterations.
+
+ - Minor formatting modifications have been made to insure convergence.
+
+ - Simplified and hopefully improved the method for guessing the starting
+ indentation level of entabbed code. Added flag -dt=n (--default_tabsize=n)
+ which might be helpful if the guessing method does not work well for
+ some editors.
+
+ - Added support for stacked labels, upper case X/B in hex and binary, and
+ CORE:: namespace.
+
+ - Eliminated warning messages for using keyword names as constants.
+
+## 2012 07 01
+
+ - Corrected problem introduced by using a chomp on scalar references, RT #77978
+
+ - Added support for Perl 5.14 package block syntax, RT #78114.
+
+ - A convergence test is made if three or more iterations are requested with
+ the -it=n parameter to avoid wasting computer time. Several hundred Mb of
+ code gleaned from the internet were searched with the results that:
+ - It is unusual for two iterations to be required unless a major
+ style change is being made.
+ - Only one case has been found where three iterations were required.
+ - No cases requiring four iterations have been found with this version.
+ For the previous version several cases where found the results could
+ oscillate between two semi-stable states. This version corrects this.
+
+ So if it is important that the code be converged it is okay to set -it=4
+ with this version and it will probably stop after the second iteration.
+
+ - Improved ability to identify and retain good line break points in the
+ input stream, such as at commas and equals. You can always tell
+ perltidy to ignore old breakpoints with -iob.
+
+ - Fixed glitch in which a terminal closing hash brace followed by semicolon
+ was not outdented back to the leading line depth like other closing
+ tokens. Thanks to Keith Neargarder for noting this.
+
+ OLD:
+ my ( $pre, $post ) = @{
+ {
+ "pp_anonlist" => [ "[", "]" ],
+ "pp_anonhash" => [ "{", "}" ]
+ }->{ $kid->ppaddr }
+ }; # terminal brace
+
+ NEW:
+ my ( $pre, $post ) = @{
+ {
+ "pp_anonlist" => [ "[", "]" ],
+ "pp_anonhash" => [ "{", "}" ]
+ }->{ $kid->ppaddr }
+ }; # terminal brace
+
+ - Removed extra indentation given to trailing 'if' and 'unless' clauses
+ without parentheses because this occasionally produced undesirable
+ results. This only applies where parens are not used after the if or
+ unless.
+
+ OLD:
+ return undef
+ unless my ( $who, $actions ) =
+ $clause =~ /^($who_re)((?:$action_re)+)$/o;
+
+ NEW:
+ return undef
+ unless my ( $who, $actions ) =
+ $clause =~ /^($who_re)((?:$action_re)+)$/o;
+
+## 2012 06 19
+
+ - Updated perltidy to handle all quote modifiers defined for perl 5 version 16.
+
+ - Side comment text in perltidyrc configuration files must now begin with
+ at least one space before the #. Thus:
+
+ OK:
+ -l=78 # Max line width is 78 cols
+ BAD:
+ -l=78# Max line width is 78 cols
+
+ This is probably true of almost all existing perltidyrc files,
+ but if you get an error message about bad parameters
+ involving a '#' the first time you run this version, please check the side
+ comments in your perltidyrc file, and add a space before the # if necessary.
+ You can quickly see the contents your perltidyrc file, if any, with the
+ command:
+
+ perltidy -dpro
+
+ The reason for this change is that some parameters naturally involve
+ the # symbol, and this can get interpreted as a side comment unless the
+ parameter is quoted. For example, to define -sphb=# it used to be necessary
+ to write
+ -sbcp='#'
+ to keep the # from becoming part of a comment. This was causing
+ trouble for new users. Now it can also be written without quotes:
+ -sbcp=#
+
+ - Fixed bug in processing some .perltidyrc files containing parameters with
+ an opening brace character, '{'. For example the following was
+ incorrectly processed:
+ --static-block-comment-prefix="^#{2,}[^\s#]"
+ Thanks to pdagosto.
+
+ - Added flag -boa (--break-at-old-attribute-breakpoints) which retains
+ any existing line breaks at attribute separation ':'. This is now the
+ default, use -nboa to deactivate. Thanks to Daphne Phister for the patch.
+ For example, given the following code, the line breaks at the ':'s will be
+ retained:
+
+ my @field
+ : field
+ : Default(1)
+ : Get('Name' => 'foo') : Set('Name');
+
+ whereas the previous version would have output a single line. If
+ the attributes are on a single line then they will remain on a single line.
+
+ - Added new flags --blank-lines-before-subs=n (-blbs=n) and
+ --blank-lines-before-packages=n (-blbp=n) to put n blank lines before
+ subs and packages. The old flag -bbs is now equivalent to -blbs=1 -blbp=1.
+ and -nbbs is equivalent to -blbs=0 -blbp=0. Requested by M. Schwern and
+ several others.
+
+ - Added feature -nsak='*' meaning no space between any keyword and opening
+ paren. This avoids listing entering a long list of keywords. Requested
+ by M. Schwern.
+
+ - Added option to delete a backup of original file with in-place-modify (-b)
+ if there were no errors. This can be requested with the flag -bext='/'.
+ See documentation for details. Requested by M. Schwern and others.
+
+ - Fixed bug where the module postfilter parameter was not applied when -b
+ flag was used. This was discovered during testing.
+
+ - Fixed in-place-modify (-b) to work with symbolic links to source files.
+ Thanks to Ted Johnson.
+
+ - Fixed bug where the Perl::Tidy module did not allow -b to be used
+ in some cases.
+
+ - No extra blank line is added before a comment which follows
+ a short line ending in an opening token, for example like this:
+ OLD:
+ if (
+
+ # unless we follow a blank or comment line
+ $last_line_leading_type !~ /^[#b]$/
+ ...
+
+ NEW:
+ if (
+ # unless we follow a blank or comment line
+ $last_line_leading_type !~ /^[#b]$/
+ ...
+
+ The blank is not needed for readability in these cases because there
+ already is already space above the comment. If a blank already
+ exists there it will not be removed, so this change should not
+ change code which has previously been formatted with perltidy.
+ Thanks to R.W.Stauner.
+
+ - Likewise, no extra blank line is added above a comment consisting of a
+ single #, since nothing is gained in readability.
+
+ - Fixed error in which a blank line was removed after a #>>> directive.
+ Thanks to Ricky Morse.
+
+ - Unnecessary semicolons after given/when/default blocks are now removed.
+
+ - Fixed bug where an unwanted blank line could be added before
+ pod text in __DATA__ or __END__ section. Thanks to jidani.
+
+ - Changed exit flags from 1 to 0 to indicate success for -help, -version,
+ and all -dump commands. Also added -? as another way to dump the help.
+ Requested by Keith Neargarder.
+
+ - Fixed bug where .ERR and .LOG files were not written except for -it=2 or more
+
+ - Fixed bug where trailing blank lines at the end of a file were dropped when
+ -it>1.
+
+ - Fixed bug where a line occasionally ended with an extra space. This reduces
+ rhe number of instances where a second iteration gives a result different
+ from the first.
+
+ - Updated documentation to note that the Tidy.pm module <stderr> parameter may
+ not be a reference to SCALAR or ARRAY; it must be a file.
+
+ - Syntax check with perl now work when the Tidy.pm module is processing
+ references to arrays and strings. Thanks to Charles Alderman.
+
+ - Zero-length files are no longer processed due to concerns for data loss
+ due to side effects in some scenarios.
+
+ - block labels, if any, are now included in closing side comment text
+ when the -csc flag is used. Suggested by Aaron. For example,
+ the label L102 in the following block is now included in the -csc text:
+
+ L102: for my $i ( 1 .. 10 ) {
+ ...
+ } ## end L102: for my $i ( 1 .. 10 )
+
+## 2010 12 17
+
+ - added new flag -it=n or --iterations=n
+ This flag causes perltidy to do n complete iterations.
+ For most purposes the default of n=1 should be satisfactory. However n=2
+ 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. The run time will be
+ approximately proportional to n, and it should seldom be necessary to use a
+ value greater than n=2. Thanks to Jonathan Swartz
+
+ - A configuration file pathname begins with three dots, e.g.
+ ".../.perltidyrc", 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.
+ Thanks to Jonathan Swartz for this patch.
+
+ - Added flag --notidy which disables all formatting and causes the input to be
+ copied unchanged. This can be useful in conjunction with hierarchical
+ F<.perltidyrc> files to prevent unwanted tidying.
+ Thanks to Jonathan Swartz for this patch.
+
+ - Added prefilters and postfilters in the call to the Tidy.pm module.
+ Prefilters and postfilters. The prefilter is a code reference that
+ will be applied to the source before tidying, and the postfilter
+ is a code reference to the result before outputting.
+
+ Thanks to Jonathan Swartz for this patch. He writes:
+ This is useful for all manner of customizations. For example, I use
+ it to convert the 'method' keyword to 'sub' so that perltidy will work for
+ Method::Signature::Simple code:
+
+ Perl::Tidy::perltidy(
+ prefilter => sub { $_ = $_[0]; s/^method (.*)/sub $1 \#__METHOD/gm; return $_ },
+ postfilter => sub { $_ = $_[0]; s/^sub (.*?)\s* \#__METHOD/method $1/gm; return $_ }
+ );
+
+ - The starting indentation level of sections of code entabbed with -et=n
+ is correctly guessed if it was also produced with the same -et=n flag. This
+ keeps the indentation stable on repeated formatting passes within an editor.
+ Thanks to Sam Kington and Glenn.
+
+ - Functions with prototype '&' had a space between the function and opening
+ peren. This space now only occurs if the flag --space-function-paren (-sfp)
+ is set. Thanks to Zrajm Akfohg.
+
+ - Patch to never put spaces around a bare word in braces beginning with ^ as in:
+ my $before = ${^PREMATCH};
+ even if requested with the -bt=0 flag because any spaces cause a syntax error in perl.
+ Thanks to Fabrice Dulanoy.
+
+## 2009 06 16
+
+ - Allow configuration file to be 'perltidy.ini' for Windows systems.
+ i.e. C:\Documents and Settings\User\perltidy.ini
+ and added documentation for setting configuation file under Windows in man
+ page. Thanks to Stuart Clark.
+
+ - Corrected problem of unwanted semicolons in hash ref within given/when code.
+ Thanks to Nelo Onyiah.
+
+ - added new flag -cscb or --closing-side-comments-balanced
+ When using closing-side-comments, and the closing-side-comment-maximum-text
+ limit is exceeded, then the comment text must be truncated. Previous
+ versions of perltidy terminate with three dots, and this can still be
+ achieved with -ncscb:
+
+ perltidy -csc -ncscb
+
+ } ## end foreach my $foo (sort { $b cmp $a ...
+
+ However this causes a problem with older editors which cannot recognize
+ comments or are not configured to doso because they cannot "bounce" around in
+ the text correctly. The B<-cscb> flag tries to help them by
+ appending appropriate terminal balancing structure:
+
+ perltidy -csc -cscb
+
+ } ## end foreach my $foo (sort { $b cmp $a ... })
+
+ Since there is much to be gained and little to be lost by doing this,
+ the default is B<-cscb>. Use B<-ncscb> if you do not want this.
+
+ Thanks to Daniel Becker for suggesting this option.
+
+ - After an isolated closing eval block the continuation indentation will be
+ removed so that the braces line up more like other blocks. Thanks to Yves Orton.
+
+ OLD:
+ eval {
+ #STUFF;
+ 1; # return true
+ }
+ or do {
+ #handle error
+ };
+
+ NEW:
+ eval {
+ #STUFF;
+ 1; # return true
+ } or do {
+ #handle error
+ };
+
+ -A new flag -asbl (or --opening-anonymous-sub-brace-on-new-line) has
+ been added to put the opening brace of anonymous sub's on a new line,
+ as in the following snippet:
+
+ my $code = sub
+ {
+ my $arg = shift;
+ return $arg->(@_);
+ };
+
+ This was not possible before because the -sbl flag only applies to named
+ subs. Thanks to Benjamin Krupp.
+
+ -Fix tokenization bug with the following snippet
+ print 'hi' if { x => 1, }->{x};
+ which resulted in a semicolon being added after the comma. The workaround
+ was to use -nasc, but this is no longer necessary. Thanks to Brian Duggan.
+
+ -Fixed problem in which an incorrect error message could be triggered
+ by the (unusual) combination of parameters -lp -i=0 -l=2 -ci=0 for
+ example. Thanks to Richard Jelinek.
+
+ -A new flag --keep-old-blank-lines=n has been added to
+ give more control over the treatment of old blank lines in
+ a script. The manual has been revised to discuss the new
+ flag and clarify the treatment of old blank lines. Thanks
+ to Oliver Schaefer.
+
+## 2007 12 05
+
+ -Improved support for perl 5.10: New quote modifier 'p', new block type UNITCHECK,
+ new keyword break, improved formatting of given/when.
+
+ -Corrected tokenization bug of something like $var{-q}.
+
+ -Numerous minor formatting improvements.
+
+ -Corrected list of operators controlled by -baao -bbao to include
+ . : ? && || and or err xor
+
+ -Corrected very minor error in log file involving incorrect comment
+ regarding need for upper case of labels.
+
+ -Fixed problem where perltidy could run for a very long time
+ when given certain non-perl text files.
+
+ -Line breaks in un-parenthesized lists now try to follow
+ line breaks in the input file rather than trying to fill
+ lines. This usually works better, but if this causes
+ trouble you can use -iob to ignore any old line breaks.
+ Example for the following input snippet:
+
+ print
+ "conformability (Not the same dimension)\n",
+ "\t", $have, " is ", text_unit($hu), "\n",
+ "\t", $want, " is ", text_unit($wu), "\n",
+ ;
+
+ OLD:
+ print "conformability (Not the same dimension)\n", "\t", $have, " is ",
+ text_unit($hu), "\n", "\t", $want, " is ", text_unit($wu), "\n",;
+
+ NEW:
+ print "conformability (Not the same dimension)\n",
+ "\t", $have, " is ", text_unit($hu), "\n",
+ "\t", $want, " is ", text_unit($wu), "\n",
+ ;
+
+## 2007 08 01
+
+ -Added -fpsc option (--fixed-position-side-comment). Thanks to Ueli Hugenschmidt.
+ For example -fpsc=40 tells perltidy to put side comments in column 40
+ if possible.
+
+ -Added -bbao and -baao options (--break-before-all-operators and
+ --break-after-all-operators) to simplify command lines and configuration
+ files. These define an initial preference for breaking at operators which can
+ be modified with -wba and -wbb flags. For example to break before all operators
+ except an = one could use --bbao -wba='=' rather than listing every
+ single perl operator (except =) on a -wbb flag.
+
+ -Added -kis option (--keep-interior-semicolons). Use the B<-kis> flag
+ to prevent breaking at a semicolon if there was no break there in the
+ input file. To illustrate, consider the following input lines:
+
+ dbmclose(%verb_delim); undef %verb_delim;
+ dbmclose(%expanded); undef %expanded;
+ dbmclose(%global); undef %global;
+
+ Normally these would be broken into six lines, but
+ perltidy -kis gives:
+
+ dbmclose(%verb_delim); undef %verb_delim;
+ dbmclose(%expanded); undef %expanded;
+ dbmclose(%global); undef %global;
+
+ -Improved formatting of complex ternary statements, with indentation
+ of nested statements.
+ OLD:
+ return defined( $cw->{Selected} )
+ ? (wantarray)
+ ? @{ $cw->{Selected} }
+ : $cw->{Selected}[0]
+ : undef;
+
+ NEW:
+ return defined( $cw->{Selected} )
+ ? (wantarray)
+ ? @{ $cw->{Selected} }
+ : $cw->{Selected}[0]
+ : undef;
+
+ -Text following un-parenthesized if/unless/while/until statements get a
+ full level of indentation. Suggested by Jeff Armstorng and others.
+ OLD:
+ return $ship->chargeWeapons("phaser-canon")
+ if $encounter->description eq 'klingon'
+ and $ship->firepower >= $encounter->firepower
+ and $location->status ne 'neutral';
+ NEW:
+ return $ship->chargeWeapons("phaser-canon")
+ if $encounter->description eq 'klingon'
+ and $ship->firepower >= $encounter->firepower
+ and $location->status ne 'neutral';
+
+## 2007 05 08
+
+ -Fixed bug where #line directives were being indented. Thanks to
+ Philippe Bruhat.
+
+## 2007 05 04
+
+ -Fixed problem where an extra blank line was added after an =cut when either
+ (a) the =cut started (not stopped) a POD section, or (b) -mbl > 1.
+ Thanks to J. Robert Ray and Bill Moseley.
+
+## 2007 04 24
+
+ -ole (--output-line-ending) and -ple (--preserve-line-endings) should
+ now work on all systems rather than just unix systems. Thanks to Dan
+ Tyrell.
+
+ -Fixed problem of a warning issued for multiple subs for BEGIN subs
+ and other control subs. Thanks to Heiko Eissfeldt.
+
+ -Fixed problem where no space was introduced between a keyword or
+ bareword and a colon, such as:
+
+ ( ref($result) eq 'HASH' && !%$result ) ? undef: $result;
+
+ Thanks to Niek.
+
+ -Added a utility program 'break_long_quotes.pl' to the examples directory of
+ the distribution. It breaks long quoted strings into a chain of concatenated
+ sub strings no longer than a selected length. Suggested by Michael Renner as
+ a perltidy feature but was judged to be best done in a separate program.
+
+ -Updated docs to remove extra < and >= from list of tokens
+ after which breaks are made by default. Thanks to Bob Kleemann.
+
+ -Removed improper uses of $_ to avoid conflicts with external calls, giving
+ error message similar to:
+ Modification of a read-only value attempted at
+ /usr/share/perl5/Perl/Tidy.pm line 6907.
+ Thanks to Michael Renner.
+
+ -Fixed problem when errorfile was not a plain filename or filehandle
+ in a call to Tidy.pm. The call
+ perltidy(source => \$input, destination => \$output, errorfile => \$err);
+ gave the following error message:
+ Not a GLOB reference at /usr/share/perl5/Perl/Tidy.pm line 3827.
+ Thanks to Michael Renner and Phillipe Bruhat.
+
+ -Fixed problem where -sot would not stack an opening token followed by
+ a side comment. Thanks to Jens Schicke.
+
+ -improved breakpoints in complex math and other long statements. Example:
+ OLD:
+ return
+ log($n) + 0.577215664901532 + ( 1 / ( 2 * $n ) ) -
+ ( 1 / ( 12 * ( $n**2 ) ) ) + ( 1 / ( 120 * ( $n**4 ) ) );
+ NEW:
+ return
+ log($n) + 0.577215664901532 +
+ ( 1 / ( 2 * $n ) ) -
+ ( 1 / ( 12 * ( $n**2 ) ) ) +
+ ( 1 / ( 120 * ( $n**4 ) ) );
+
+ -more robust vertical alignment of complex terminal else blocks and ternary
+ statements.
+
+## 2006 07 19
+
+ -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern
+ replacement text was not recognized. The tokenizer now recursively scans
+ replacement text (but does not reformat it).
+
+ -improved vertical alignment of terminal else blocks and ternary statements.
+ Thanks to Chris for the suggestion.
+
+ OLD:
+ if ( IsBitmap() ) { return GetBitmap(); }
+ elsif ( IsFiles() ) { return GetFiles(); }
+ else { return GetText(); }
+
+ NEW:
+ if ( IsBitmap() ) { return GetBitmap(); }
+ elsif ( IsFiles() ) { return GetFiles(); }
+ else { return GetText(); }
+
+ OLD:
+ $which_search =
+ $opts{"t"} ? 'title'
+ : $opts{"s"} ? 'subject'
+ : $opts{"a"} ? 'author'
+ : 'title';
+
+ NEW:
+ $which_search =
+ $opts{"t"} ? 'title'
+ : $opts{"s"} ? 'subject'
+ : $opts{"a"} ? 'author'
+ : 'title';
+
+ -improved indentation of try/catch blocks and other externally defined
+ functions accepting a block argument. Thanks to jae.
+
+ -Added support for Perl 5.10 features say and smartmatch.
+
+ -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters
+ suggested in Damian Conway's "Perl Best Practices". -pbp is the same as:
+
+ -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
+ -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < =
+ **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
+
+ Please note that the -st here restricts input to standard input; use
+ -nst if necessary to override.
+
+ -Eliminated some needless breaks at equals signs in -lp indentation.
+
+ OLD:
+ $c =
+ Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
+ TOP + $y * (BOTTOM - TOP) / SIZE);
+ NEW:
+ $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
+ TOP + $y * (BOTTOM - TOP) / SIZE);
+
+ A break at an equals is sometimes useful for preventing complex statements
+ from hitting the line length limit. The decision to do this was
+ over-eager in some cases and has been improved. Thanks to Royce Reece.
+
+ -qw quotes contained in braces, square brackets, and parens are being
+ treated more like those containers as far as stacking of tokens. Also
+ stack of closing tokens ending ');' will outdent to where the ');' would
+ have outdented if the closing stack is matched with a similar opening stack.
+
+ OLD: perltidy -soc -sct
+ __PACKAGE__->load_components(
+ qw(
+ PK::Auto
+ Core
+ )
+ );
+ NEW: perltidy -soc -sct
+ __PACKAGE__->load_components( qw(
+ PK::Auto
+ Core
+ ) );
+ Thanks to Aran Deltac
+
+ -Eliminated some undesirable or marginally desirable vertical alignments.
+ These include terminal colons, opening braces, and equals, and particularly
+ when just two lines would be aligned.
+
+ OLD:
+ my $accurate_timestamps = $Stamps{lnk};
+ my $has_link =
+ ...
+ NEW:
+ my $accurate_timestamps = $Stamps{lnk};
+ my $has_link =
+
+ -Corrected a problem with -mangle in which a space would be removed
+ between a keyword and variable beginning with ::.
+
+## 2006 06 14
+
+ -Attribute argument lists are now correctly treated as quoted strings
+ and not formatted. This is the most important update in this version.
+ Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup.
+
+ -Updated to recognize the defined or operator, //, to be released in Perl 10.
+ Thanks to Sebastien Aperghis-Tramoni.
+
+ -A useful utility perltidyrc_dump.pl is included in the examples section. It
+ will read any perltidyrc file and write it back out in a standard format
+ (though comments are lost).
+
+ -Added option to have perltidy read and return a hash with the contents of a
+ perltidyrc file. This may be used by Leif Eriksen's tidyview code. This
+ feature is used by the demonstration program 'perltidyrc_dump.pl' in the
+ examples directory.
+
+ -Improved error checking in perltidyrc files. Unknown bare words were not
+ being caught.
+
+ -The --dump-options parameter now dumps parameters in the format required by a
+ perltidyrc file.
+
+ -V-Strings with underscores are now recognized.
+ For example: $v = v1.2_3;
+
+ -cti=3 option added which gives one extra indentation level to closing
+ tokens always. This provides more predictable closing token placement
+ than cti=2. If you are using cti=2 you might want to try cti=3.
+
+ -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>.
+
+ -New parameters -fs, -fsb, -fse added to allow sections of code between #<<<
+ and #>>> to be passed through verbatim. This is enabled by default and turned
+ off by -nfs. Flags -fsb and -fse allow other beginning and ending markers.
+ Thanks to Wolfgang Werner and Marion Berryman for suggesting this.
+
+ -added flag -skp to put a space between all Perl keywords and following paren.
+ The default is to only do this for certain keywords. Suggested by
+ H.Merijn Brand.
+
+ -added flag -sfp to put a space between a function name and following paren.
+ The default is not to do this. Suggested by H.Merijn Brand.
+
+ -Added patch to avoid breaking GetOpt::Long::Configure set by calling program.
+ Thanks to Philippe Bruhat.
+
+ -An error was fixed in which certain parameters in a .perltidyrc file given
+ without the equals sign were not recognized. That is,
+ '--brace-tightness 0' gave an error but '--brace-tightness=0' worked
+ ok. Thanks to Zac Hansen.
+
+ -An error preventing the -nwrs flag from working was corrected. Thanks to
+ Greg Ferguson.
+
+ -Corrected some alignment problems with entab option.
+
+ -A bug with the combination of -lp and -extrude was fixed (though this
+ combination doesn't really make sense). The bug was that a line with
+ a single zero would be dropped. Thanks to Cameron Hayne.
+
+ -Updated Windows detection code to avoid an undefined variable.
+ Thanks to Joe Yates and Russ Jones.
+
+ -Improved formatting for short trailing statements following a closing paren.
+ Thanks to Joe Matarazzo.
+
+ -The handling of the -icb (indent closing block braces) flag has been changed
+ slightly to provide more consistent and predictable formatting of complex
+ structures. Instead of giving a closing block brace the indentation of the
+ previous line, it is now given one extra indentation level. The two methods
+ give the same result if the previous line was a complete statement, as in this
+ example:
+
+ if ($task) {
+ yyy();
+ } # -icb
+ else {
+ zzz();
+ }
+ The change also fixes a problem with empty blocks such as:
+
+ OLD, -icb:
+ elsif ($debug) {
+ }
+
+ NEW, -icb:
+ elsif ($debug) {
+ }
+
+ -A problem with -icb was fixed in which a closing brace was misplaced when
+ it followed a quote which spanned multiple lines.
+
+ -Some improved breakpoints for -wba='&& || and or'
+
+ -Fixed problem with misaligned cuddled else in complex statements
+ when the -bar flag was also used. Thanks to Alex and Royce Reese.
+
+ -Corrected documentation to show that --outdent-long-comments is the default.
+ Thanks to Mario Lia.
+
+ -New flag -otr (opening-token-right) is similar to -bar (braces-always-right)
+ but applies to non-structural opening tokens.
+
+ -new flags -sot (stack-opening-token), -sct (stack-closing-token).
+ Suggested by Tony.
+
+## 2003 10 21
+
+ -The default has been changed to not do syntax checking with perl.
+ Use -syn if you want it. Perltidy is very robust now, and the -syn
+ flag now causes more problems than it's worth because of BEGIN blocks
+ (which get executed with perl -c). For example, perltidy will never
+ return when trying to beautify this code if -syn is used:
+
+ BEGIN { 1 while { }; }
+
+ Although this is an obvious error, perltidy is often run on untested
+ code which is more likely to have this sort of problem. A more subtle
+ example is:
+
+ BEGIN { use FindBin; }
+
+ which may hang on some systems using -syn if a shared file system is
+ unavailable.
+
+ -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item).
+ In most cases it looks better. To recover the previous format, use
+ '-gnu -cti=2'
+
+ -Added flags -cti=n for finer control of closing token indentation.
+ -cti = 0 no extra indentation (default; same as -nicp)
+ -cti = 1 enough indentation so that the closing token
+ aligns with its opening token.
+ -cti = 2 one extra indentation level if the line has the form
+ ); ]; or }; (same as -icp).
+
+ The new option -cti=1 works well with -lp:
+
+ EXAMPLES:
+
+ # perltidy -lp -cti=1
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ # perltidy -lp -cti=2
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+ This is backwards compatible with -icp. See revised manual for
+ details. Suggested by Mike Pennington.
+
+ -Added flag '--preserve-line-endings' or '-ple' to cause the output
+ line ending to be the same as in the input file, for unix, dos,
+ or mac line endings. Only works under unix. Suggested by
+ Rainer Hochschild.
+
+ -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win,
+ unix, or mac. Only works under unix.
+
+ -Files with Mac line endings should now be handled properly under unix
+ and dos without being passed through a converter.
+
+ -You may now include 'and', 'or', and 'xor' in the list following
+ '--want-break-after' to get line breaks after those keywords rather than
+ before them. Suggested by Rainer Hochschild.
+
+ -Corrected problem with command line option for -vtc=n and -vt=n. The
+ equals sign was being eaten up by the Windows shell so perltidy didn't
+ see it.
+
+## 2003 07 26
+
+ -Corrected cause of warning message with recent versions of Perl:
+ "Possible precedence problem on bitwise & operator at ..."
+ Thanks to Jim Files.
+
+ -fixed bug with -html with '=for pod2html' sections, in which code/pod
+ output order was incorrect. Thanks to Tassilo von Parseval.
+
+ -fixed bug when the -html flag is used, in which the following error
+ message, plus others, appear:
+ did not see <body> in pod2html output
+ This was caused by a change in the format of html output by pod2html
+ VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval.
+
+ -Fixed bug where an __END__ statement would be mistaken for a label
+ if it is immediately followed by a line with a leading colon. Thanks
+ to John Bayes.
+
+ -Implemented guessing logic for brace types when it is ambiguous. This
+ has been on the TODO list a long time. Thanks to Boris Zentner for
+ an example.
+
+ -Long options may now be negated either as '--nolong-option'
+ or '--no-long-option'. Thanks to Philip Newton for the suggestion.
+
+ -added flag --html-entities or -hent which controls the use of
+ Html::Entities for html formatting. Use --nohtml-entities or -nhent to
+ prevent the use of Html::Entities to encode special symbols. The
+ default is -hent. Html::Entities when formatting perl text to escape
+ special symbols. This may or may not be the right thing to do,
+ depending on browser/language combinations. Thanks to Burak Gursoy for
+ this suggestion.
+
+ -Bareword strings with leading '-', like, '-foo' now count as 1 token
+ for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo}
+ are now all treated similarly. Thus, by default, OLD: $a{ -foo } will
+ now be NEW: $a{-foo}. Suggested by Mark Olesen.
+
+ -added 2 new flags to control spaces between keywords and opening parens:
+ -sak=s or --space-after-keyword=s, and
+ -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords.
+
+ The new default list of keywords which get a space is:
+
+ "my local our and or eq ne if else elsif until unless while for foreach
+ return switch case given when"
+
+ Use -sak=s and -nsak=s to add and remove keywords from this list,
+ respectively.
+
+ Explanation: Stephen Hildrey noted that perltidy was being inconsistent
+ in placing spaces between keywords and opening parens, and sent a patch
+ to give user control over this. The above list was selected as being
+ a reasonable default keyword list. Previously, perltidy
+ had a hardwired list which also included these keywords:
+
+ push pop shift unshift join split die
+
+ but did not have 'our'. Example: if you prefer to make perltidy behave
+ exactly as before, you can include the following two lines in your
+ .perltidyrc file:
+
+ -sak="push pop local shift unshift join split die"
+ -nsak="our"
+
+ -Corrected html error in .toc file when -frm -html is used (extra ");
+ browsers were tolerant of it.
+
+ -Improved alignment of chains of binary and ?/: operators. Example:
+ OLD:
+ $leapyear =
+ $year % 4 ? 0
+ : $year % 100 ? 1
+ : $year % 400 ? 0
+ : 1;
+ NEW:
+ $leapyear =
+ $year % 4 ? 0
+ : $year % 100 ? 1
+ : $year % 400 ? 0
+ : 1;
+
+ -improved breakpoint choices involving '->'
+
+ -Corrected tokenization of things like ${#}. For example,
+ ${#} is valid, but ${# } is a syntax error.
+
+ -Corrected minor tokenization errors with indirect object notation.
+ For example, 'new A::()' works now.
+
+ -Minor tokenization improvements; all perl code distributed with perl 5.8
+ seems to be parsed correctly except for one instance (lextest.t)
+ of the known bug.
+
+## 2002 11 30
+
+ -Implemented scalar attributes. Thanks to Sean Tobin for noting this.
+
+ -Fixed glitch introduced in previous release where -pre option
+ was not outputting a leading html <pre> tag.
+
+ -Numerous minor improvements in vertical alignment, including the following:
+
+ -Improved alignment of opening braces in many cases. Needed for improved
+ switch/case formatting, and also suggested by Mark Olesen for sort/map/grep
+ formatting. For example:
+
+ OLD:
+ @modified =
+ map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, -M ] } @filenames;
+
+ NEW:
+ @modified =
+ map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, -M ] } @filenames;
+
+ -Eliminated alignments across unrelated statements. Example:
+ OLD:
+ $borrowerinfo->configure( -state => 'disabled' );
+ $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
+
+ NEW:
+ $borrowerinfo->configure( -state => 'disabled' );
+ $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
+
+ Thanks to Mark Olesen for suggesting this.
+
+ -Improved alignement of '='s in certain cases.
+ Thanks to Norbert Gruener for sending an example.
+
+ -Outdent-long-comments (-olc) has been re-instated as a default, since
+ it works much better now. Use -nolc if you want to prevent it.
+
+ -Added check for 'perltidy file.pl -o file.pl', which causes file.pl
+ to be lost. (The -b option should be used instead). Thanks to mreister
+ for reporting this problem.
+
+## 2002 11 06
+
+ -Switch/case or given/when syntax is now recognized. Its vertical alignment
+ is not great yet, but it parses ok. The words 'switch', 'case', 'given',
+ and 'when' are now treated as keywords. If this causes trouble with older
+ code, we could introduce a switch to deactivate it. Thanks to Stan Brown
+ and Jochen Schneider for recommending this.
+
+ -Corrected error parsing sub attributes with call parameters.
+ Thanks to Marc Kerr for catching this.
+
+ -Sub prototypes no longer need to be on the same line as sub names.
+
+ -a new flag -frm or --frames will cause html output to be in a
+ frame, with table of contents in the left panel and formatted source
+ in the right panel. Try 'perltidy -html -frm somemodule.pm' for example.
+
+ -The new default for -html formatting is to pass the pod through Pod::Html.
+ The result is syntax colored code within your pod documents. This can be
+ deactivated with -npod. Thanks to those who have written to discuss this,
+ particularly Mark Olesen and Hugh Myers.
+
+ -the -olc (--outdent-long-comments) option works much better. It now outdents
+ groups of consecutive comments together, and by just the amount needed to
+ avoid having any one line exceeding the maximum line length.
+
+ -block comments are now trimmed of trailing whitespace.
+
+ -if a directory specified with -opath does not exist, it will be created.
+
+ -a table of contents to packages and subs is output when -html is used.
+ Use -ntoc to prevent this.
+
+ -fixed an unusual bug in which a 'for' statement following a 'format'
+ statement was not correctly tokenized. Thanks to Boris Zentner for
+ catching this.
+
+ -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray.
+ There were some speed issues. Suggested by Joerg Walter.
+
+ -The treatment of quoted wildcards (file globs) is now system-independent.
+ For example
+
+ perltidy 'b*x.p[lm]'
+
+ would match box.pl, box.pm, brinx.pm under any operating system. Of
+ course, anything unquoted will be subject to expansion by any shell.
+
+ -default color for keywords under -html changed from
+ SaddleBrown (#8B4513) to magenta4 (#8B008B).
+
+ -fixed an arg parsing glitch in which something like:
+ perltidy quick-help
+ would trigger the help message and exit, rather than operate on the
+ file 'quick-help'.
+
+## 2002 09 22
+
+ -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to
+ overwrite the original file with the tidied output file. The original
+ file will be saved with a '.bak' extension (which can be changed with
+ -bext=s). Thanks to Rudi Farkas for the suggestion.
+
+ -An index to all subs is included at the top of -html output, unless
+ only the <pre> section is written.
+
+ -Anchor lines of the form <a name="mysub"></a> are now inserted at key points
+ in html output, such as before sub definitions, for the convenience of
+ postprocessing scripts. Suggested by Howard Owen.
+
+ -The cuddled-else (-ce) flag now also makes cuddled continues, like
+ this:
+
+ while ( ( $pack, $file, $line ) = caller( $i++ ) ) {
+ # bla bla
+ } continue {
+ $prevpack = $pack;
+ }
+
+ Suggested by Simon Perreault.
+
+ -Fixed bug in which an extra blank line was added before an =head or
+ similar pod line after an __END__ or __DATA__ line each time
+ perltidy was run. Also, an extra blank was being added after
+ a terminal =cut. Thanks to Mike Birdsall for reporting this.
+
+## 2002 08 26
+
+ -Fixed bug in which space was inserted in a hyphenated hash key:
+ my $val = $myhash{USER-NAME};
+ was converted to:
+ my $val = $myhash{USER -NAME};
+ Thanks to an anonymous bug reporter at sourceforge.
+
+ -Fixed problem with the '-io' ('--indent-only') where all lines
+ were double spaced. Thanks to Nick Andrew for reporting this bug.
+
+ -Fixed tokenization error in which something like '-e1' was
+ parsed as a number.
+
+ -Corrected a rare problem involving older perl versions, in which
+ a line break before a bareword caused problems with 'use strict'.
+ Thanks to Wolfgang Weisselberg for noting this.
+
+ -More syntax error checking added.
+
+ -Outdenting labels (-ola) has been made the default, in order to follow the
+ perlstyle guidelines better. It's probably a good idea in general, but
+ if you do not want this, use -nola in your .perltidyrc file.
+
+ -Updated rules for padding logical expressions to include more cases.
+ Thanks to Wolfgang Weisselberg for helpful discussions.
+
+ -Added new flag -osbc (--outdent-static-block-comments) which will
+ outdent static block comments by 2 spaces (or whatever -ci equals).
+ Requested by Jon Robison.
+
+## 2002 04 25
+
+ -Corrected a bug, introduced in the previous release, in which some
+ closing side comments (-csc) could have incorrect text. This is
+ annoying but will be correct the next time perltidy is run with -csc.
+
+ -Fixed bug where whitespace was being removed between 'Bar' and '()'
+ in a use statement like:
+
+ use Foo::Bar ();
+
+ -Whenever possible, if a logical expression is broken with leading
+ '&&', '||', 'and', or 'or', then the leading line will be padded
+ with additional space to produce alignment. This has been on the
+ todo list for a long time; thanks to Frank Steinhauer for reminding
+ me to do it. Notice the first line after the open parens here:
+
+ OLD: perltidy -lp
+ if (
+ !param("rules.to.$linecount")
+ && !param("rules.from.$linecount")
+ && !param("rules.subject.$linecount")
+ && !(
+ param("rules.fieldname.$linecount")
+ && param("rules.fieldval.$linecount")
+ )
+ && !param("rules.size.$linecount")
+ && !param("rules.custom.$linecount")
+ )
+
+ NEW: perltidy -lp
+ if (
+ !param("rules.to.$linecount")
+ && !param("rules.from.$linecount")
+ && !param("rules.subject.$linecount")
+ && !(
+ param("rules.fieldname.$linecount")
+ && param("rules.fieldval.$linecount")
+ )
+ && !param("rules.size.$linecount")
+ && !param("rules.custom.$linecount")
+ )
+
+## 2002 04 16
+
+ -Corrected a mistokenization of variables for a package with a name
+ equal to a perl keyword. For example:
+
+ my::qx();
+ package my;
+ sub qx{print "Hello from my::qx\n";}
+
+ In this case, the leading 'my' was mistokenized as a keyword, and a
+ space was being place between 'my' and '::'. This has been
+ corrected. Thanks to Martin Sluka for discovering this.
+
+ -A new flag -bol (--break-at-old-logic-breakpoints)
+ has been added to control whether containers with logical expressions
+ should be broken open. This is the default.
+
+ -A new flag -bok (--break-at-old-keyword-breakpoints)
+ has been added to follow breaks at old keywords which return lists,
+ such as sort and map. This is the default.
+
+ -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to
+ follow breaks at trinary (conditional) operators. This is the default.
+
+ -A new flag -cab=n has been added to control breaks at commas after
+ '=>' tokens. The default is n=1, meaning break unless this breaks
+ open an existing on-line container.
+
+ -A new flag -boc has been added to allow existing list formatting
+ to be retained. (--break-at-old-comma-breakpoints). See updated manual.
+
+ -A new flag -iob (--ignore-old-breakpoints) has been added to
+ prevent the locations of old breakpoints from influencing the output
+ format.
+
+ -Corrected problem where nested parentheses were not getting full
+ indentation. This has been on the todo list for some time; thanks
+ to Axel Rose for a snippet demonstrating this issue.
+
+ OLD: inner list is not indented
+ $this->sendnumeric(
+ $this->server,
+ (
+ $ret->name, $user->username, $user->host,
+ $user->server->name, $user->nick, "H"
+ ),
+ );
+
+ NEW:
+ $this->sendnumeric(
+ $this->server,
+ (
+ $ret->name, $user->username, $user->host,
+ $user->server->name, $user->nick, "H"
+ ),
+ );
+
+ -Code cleaned up by removing the following unused, undocumented flags.
+ They should not be in any .perltidyrc files because they were just
+ experimental flags which were never documented. Most of them placed
+ artificial limits on spaces, and Wolfgang Weisselberg convinced me that
+ most of them they do more harm than good by causing unexpected results.
+
+ --maximum-continuation-indentation (-mci)
+ --maximum-whitespace-columns
+ --maximum-space-to-comment (-xsc)
+ --big-space-jump (-bsj)
+
+ -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and
+ Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's
+ were having trouble.
+
+ -A new flag -isbc has been added for more control on comments. This flag
+ has the effect that if there is no leading space on the line, then the
+ comment will not be indented, and otherwise it may be. If both -ibc and
+ -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer
+ for suggesting this.
+
+ -A new document 'stylekey.pod' has been created to quickly guide new users
+ through the maze of perltidy style parameters. An html version is
+ on the perltidy web page. Take a look! It should be very helpful.
+
+ -Parameters for controlling 'vertical tightness' have been added:
+ -vt and -vtc are the main controls, but finer control is provided
+ with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical
+ tightness controls have also been added.
+ See updated manual and also see 'stylekey.pod'. Simple examples:
+
+ # perltidy -lp -vt=1 -vtc=1
+ @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
+
+ # perltidy -lp -vt=1 -vtc=0
+ @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ -Lists which do not format well in uniform columns are now better
+ identified and formated.
+
+ OLD:
+ return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'},
+ $y + $ruler_info{'size'}, $x - $ruler_info{'size'},
+ $y + $ruler_info{'size'} );
+
+ NEW:
+ return $c->create(
+ 'polygon', $x, $y,
+ $x + $ruler_info{'size'},
+ $y + $ruler_info{'size'},
+ $x - $ruler_info{'size'},
+ $y + $ruler_info{'size'}
+ );
+
+ OLD:
+ radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ',
+ 'None', 'Default', 'Default', 'Simple', 'Simple');
+ NEW:
+ radlablist($f1,
+ pad('Initial', $p),
+ $b->{Init}->get_panel_ref,
+ 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple');
+
+ -Corrected problem where an incorrect html filename was generated for
+ external calls to Tidy.pm module. Fixed incorrect html title when
+ Tidy.pm is called with IO::Scalar or IO::Array source.
+
+ -Output file permissons are now set as follows. An output script file
+ gets the same permission as the input file, except that owner
+ read/write permission is added (otherwise, perltidy could not be
+ rerun). Html output files use system defaults. Previously chmod 0755
+ was used in all cases. Thanks to Mark Olesen for bringing this up.
+
+ -Missing semicolons will not be added in multi-line blocks of type
+ sort, map, or grep. This brings perltidy into closer agreement
+ with common practice. Of course, you can still put semicolons
+ there if you like. Thanks to Simon Perreault for a discussion of this.
+
+ -Most instances of extra semicolons are now deleted. This is
+ particularly important if the -csc option is used. Thanks to Wolfgang
+ Weisselberg for noting this. For example, the following line
+ (produced by 'h2xs' :) has an extra semicolon which will now be
+ removed:
+
+ BEGIN { plan tests => 1 };
+
+ -New parameter -csce (--closing-side-comment-else-flag) can be used
+ to control what text is appended to 'else' and 'elsif' blocks.
+ Default is to just add leading 'if' text to an 'else'. See manual.
+
+ -The -csc option now labels 'else' blocks with additinal information
+ from the opening if statement and elsif statements, if space.
+ Thanks to Wolfgang Weisselberg for suggesting this.
+
+ -The -csc option will now remove any old closing side comments
+ below the line interval threshold. Thanks to Wolfgang Weisselberg for
+ suggesting this.
+
+ -The abbreviation feature, which was broken in the previous version,
+ is now fixed. Thanks to Michael Cartmell for noting this.
+
+ -Vertical alignment is now done for '||=' .. somehow this was
+ overlooked.
+
+## 2002 02 25
+
+ -This version uses modules for the first time, and a standard perl
+ Makefile.PL has been supplied. However, perltidy may still be
+ installed as a single script, without modules. See INSTALL for
+ details.
+
+ -The man page 'perl2web' has been merged back into the main 'perltidy'
+ man page to simplify installation. So you may remove that man page
+ if you have an older installation.
+
+ -Added patch from Axel Rose for MacPerl. The patch prompts the user
+ for command line arguments before calling the module
+ Perl::Tidy::perltidy.
+
+ -Corrected bug with '-bar' which was introduced in the previous
+ version. A closing block brace was being indented. Thanks to
+ Alexandros M Manoussakis for reporting this.
+
+ -New parameter '--entab-leading-whitespace=n', or '-et=n', has been
+ added for those who prefer tabs. This behaves different from the
+ existing '-t' parameter; see updated man page. Suggested by Mark
+ Olesen.
+
+ -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be
+ used to change the flags passed to perltidy in a syntax check.
+ See updated man page. Suggested by Mark Olesen.
+
+ -New parameter '--output-path=s' or '-opath=s' will cause output
+ files to be placed in directory s. See updated man page. Thanks for
+ Mark Olesen for suggesting this.
+
+ -New parameter --dump-profile (or -dpro) will dump to
+ standard output information about the search for a
+ configuration file, the name of whatever configuration file
+ is selected, and its contents. This should help debugging
+ config files, especially on different Windows systems.
+
+ -The -w parameter now notes possible errors of the form:
+
+ $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace
+
+ -Corrections added for a leading ':' and for leaving a leading 'tcsh'
+ line untouched. Mark Olesen reported that lines of this form were
+ accepted by perl but not by perltidy:
+
+ : # use -*- perl -*-
+ eval 'exec perl -wS $0 "$@"' # shell should exec 'perl'
+ unless 1; # but Perl should skip this one
+
+ Perl will silently swallow a leading colon on line 1 of a
+ script, and now perltidy will do likewise. For example,
+ this is a valid script, provided that it is the first line,
+ but not otherwise:
+
+ : print "Hello World\n";
+
+ Also, perltidy will now mark a first line with leading ':' followed by
+ '#' as type SYSTEM (just as a #! line), not to be formatted.
+
+ -List formatting improved for certain lists with special
+ initial terms, such as occur with 'printf', 'sprintf',
+ 'push', 'pack', 'join', 'chmod'. The special initial term is
+ now placed on a line by itself. For example, perltidy -gnu
+
+ OLD:
+ $Addr = pack(
+ "C4", hex($SourceAddr[0]),
+ hex($SourceAddr[1]), hex($SourceAddr[2]),
+ hex($SourceAddr[3])
+ );
+
+ NEW:
+ $Addr = pack("C4",
+ hex($SourceAddr[0]), hex($SourceAddr[1]),
+ hex($SourceAddr[2]), hex($SourceAddr[3]));
+
+ OLD:
+ push (
+ @{$$self{states}}, '64', '66', '68',
+ '70', '72', '74', '76',
+ '78', '80', '82', '84',
+ '86', '88', '90', '92',
+ '94', '96', '98', '100',
+ '102', '104'
+ );
+
+ NEW:
+ push (
+ @{$$self{states}},
+ '64', '66', '68', '70', '72', '74', '76',
+ '78', '80', '82', '84', '86', '88', '90',
+ '92', '94', '96', '98', '100', '102', '104'
+ );
+
+ -Lists of complex items, such as matricies, are now detected
+ and displayed with just one item per row:
+
+ OLD:
+ $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
+ [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ],
+ [ 0, 0, 1 ]
+ );
+
+ NEW:
+ $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
+ [ 1, tan( deg2rad($a) ), 0 ],
+ [ tan( deg2rad($b) ), 1, 0 ],
+ [ 0, 0, 1 ]
+ );
+
+ -The perl syntax check will be turned off for now when input is from
+ standard input or standard output. The reason is that this requires
+ temporary files, which has produced far too many problems during
+ Windows testing. For example, the POSIX module under Windows XP/2000
+ creates temporary names in the root directory, to which only the
+ administrator should have permission to write.
+
+ -Merged patch sent by Yves Orton to handle appropriate
+ configuration file locations for different Windows varieties
+ (2000, NT, Me, XP, 95, 98).
+
+ -Added patch to properly handle a for/foreach loop without
+ parens around a list represented as a qw. I didn't know this
+ was possible until Wolfgang Weisselberg pointed it out:
+
+ foreach my $key qw\Uno Due Tres Quadro\ {
+ print "Set $key\n";
+ }
+
+ But Perl will give a syntax error without the $ variable; ie this will
+ not work:
+
+ foreach qw\Uno Due Tres Quadro\ {
+ print "Set $_\n";
+ }
+
+ -Merged Windows version detection code sent by Yves Orton. Perltidy
+ now automatically turns off syntax checking for Win 9x/ME versions,
+ and this has solved a lot of robustness problems. These systems
+ cannot reliably handle backtick operators. See man page for
+ details.
+
+ -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid
+ output filenames were being created in some cases).
+
+ -Numerous minor improvements have been made for -lp style indentation.
+
+ -Long C-style 'for' expressions will be broken after each ';'.
+
+ 'perltidy -gnu' gives:
+
+ OLD:
+ for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0
+ and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()))
+
+ NEW:
+ for ($status = $db->seq($key, $value, R_CURSOR()) ;
+ $status == 0 and $key eq $origkey ;
+ $status = $db->seq($key, $value, R_NEXT()))
+
+ -For the -lp option, a single long term within parens
+ (without commas) now has better alignment. For example,
+ perltidy -gnu
+
+ OLD:
+ $self->throw("Must specify a known host, not $location,"
+ . " possible values ("
+ . join (",", sort keys %hosts) . ")");
+
+ NEW:
+ $self->throw("Must specify a known host, not $location,"
+ . " possible values ("
+ . join (",", sort keys %hosts) . ")");
+
+## 2001 12 31
+
+ -This version is about 20 percent faster than the previous
+ version as a result of optimization work. The largest gain
+ came from switching to a dispatch hash table in the
+ tokenizer.
+
+ -perltidy -html will check to see if HTML::Entities is
+ installed, and if so, it will use it to encode unsafe
+ characters.
+
+ -Added flag -oext=ext to change the output file extension to
+ be different from the default ('tdy' or 'html'). For
+ example:
+
+ perltidy -html -oext=htm filename
+
+ will produce filename.htm
+
+ -Added flag -cscw to issue warnings if a closing side comment would replace
+ an existing, different side comments. See the man page for details.
+ Thanks to Peter Masiar for helpful discussions.
+
+ -Corrected tokenization error of signed hex/octal/binary numbers. For
+ example, the first hex number below would have been parsed correctly
+ but the second one was not:
+ if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { }
+
+ -'**=' was incorrectly tokenized as '**' and '='. This only
+ caused a problem with the -extrude opton.
+
+ -Corrected a divide by zero when -extrude option is used
+
+ -The flag -w will now contain all errors reported by 'perl -c' on the
+ input file, but otherwise they are not reported. The reason is that
+ perl will report lots of problems and syntax errors which are not of
+ interest when only a small snippet is being formatted (such as missing
+ modules and unknown bare words). Perltidy will always report all
+ significant syntax errors that it finds, such as unbalanced braces,
+ unless the -q (quiet) flag is set.
+
+ -Merged modifications created by Hugh Myers into perltidy.
+ These include a 'streamhandle' routine which allows perltidy
+ as a module to operate on input and output arrays and strings
+ in addition to files. Documentation and new packaging as a
+ module should be ready early next year; This is an elegant,
+ powerful update; many thanks to Hugh for contributing it.
+
+## 2001 11 28
+
+ -added a tentative patch which tries to keep any existing breakpoints
+ at lines with leading keywords map,sort,eval,grep. The idea is to
+ improve formatting of sequences of list operations, as in a schwartzian
+ transform. Example:
+
+ INPUT:
+ my @sorted = map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, rand ] } @list;
+
+ OLD:
+ my @sorted =
+ map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
+
+ NEW:
+ my @sorted = map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, rand ] } @list;
+
+ The new alignment is not as nice as the input, but this is an improvement.
+ Thanks to Yves Orton for this suggestion.
+
+ -modified indentation logic so that a line with leading opening paren,
+ brace, or square bracket will never have less indentation than the
+ line with the corresponding opening token. Here's a simple example:
+
+ OLD:
+ $mw->Button(
+ -text => "New Document",
+ -command => \&new_document
+ )->pack(
+ -side => 'bottom',
+ -anchor => 'e'
+ );
+
+ Note how the closing ');' is lined up with the first line, even
+ though it closes a paren in the 'pack' line. That seems wrong.
+
+ NEW:
+ $mw->Button(
+ -text => "New Document",
+ -command => \&new_document
+ )->pack(
+ -side => 'bottom',
+ -anchor => 'e'
+ );
+
+ This seems nicer: you can up-arrow with an editor and arrive at the
+ opening 'pack' line.
+
+ -corrected minor glitch in which cuddled else (-ce) did not get applied
+ to an 'unless' block, which should look like this:
+
+ unless ($test) {
+
+ } else {
+
+ }
+
+ Thanks to Jeremy Mates for reporting this.
+
+ -The man page has been reorganized to parameters easier to find.
+
+ -Added check for multiple definitions of same subroutine. It is easy
+ to introduce this problem when cutting and pasting. Perl does not
+ complain about it, but it can lead to disaster.
+
+ -The command -pro=filename or -profile=filename 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 '=' sign. I needed
+ this to be able to easily test perltidy with a variety of different
+ configuration files.
+
+ -Side comment alignment has been improved somewhat across frequent level
+ changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg
+ for pointing out this problem. For example:
+
+ OLD:
+ if ( ref $self ) { # Called as a method
+ $format = shift;
+ }
+ else { # Regular procedure call
+ $format = $self;
+ undef $self;
+ }
+
+ NEW:
+ if ( ref $self ) { # Called as a method
+ $format = shift;
+ }
+ else { # Regular procedure call
+ $format = $self;
+ undef $self;
+ }
+
+ -New command -ssc (--static-side-comment) and related command allows
+ side comments to be spaced close to preceding character. This is
+ useful for displaying commented code as side comments.
+
+ -New command -csc (--closing-side-comment) and several related
+ commands allow comments to be added to (and deleted from) any or all
+ closing block braces. This can be useful if you have to maintain large
+ programs, especially those that you didn't write. See updated man page.
+ Thanks to Peter Masiar for this suggestion. For a simple example:
+
+ perltidy -csc
+
+ sub foo {
+ if ( !defined( $_[0] ) ) {
+ print("Hello, World\n");
+ }
+ else {
+ print( $_[0], "\n" );
+ }
+ } ## end sub foo
+
+ This added '## end sub foo' to the closing brace.
+ To remove it, perltidy -ncsc.
+
+ -New commands -ola, for outdenting labels, and -okw, for outdenting
+ selected control keywords, were implemented. See the perltidy man
+ page for details. Thanks to Peter Masiar for this suggestion.
+
+ -Hanging side comment change: a comment will not be considered to be a
+ hanging side comment if there is no leading whitespace on the line.
+ This should improve the reliability of identifying hanging side comments.
+ Thanks to Peter Masiar for this suggestion.
+
+ -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc
+ (outdent-long-comments), have been added. The original -oll
+ (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc.
+ The new default is just -olq. This was necessary to avoid inconsistency with
+ the new static block comment option.
+
+ -Static block comments: to provide a way to display commented code
+ better, the convention is used that comments with a leading '##' should
+ not be formatted as usual. Please see '-sbc' (or '--static-block-comment')
+ for documentation. It can be deactivated with with -nsbc, but
+ should not normally be necessary. Thanks to Peter Masiar for this
+ suggestion.
+
+ -Two changes were made to help show structure of complex lists:
+ (1) breakpoints are forced after every ',' in a list where any of
+ the list items spans multiple lines, and
+ (2) List items which span multiple lines now get continuation indentation.
+
+ The following example illustrates both of these points. Many thanks to
+ Wolfgang Weisselberg for this snippet and a discussion of it; this is a
+ significant formatting improvement. Note how it is easier to see the call
+ parameters in the NEW version:
+
+ OLD:
+ assert( __LINE__, ( not defined $check )
+ or ref $check
+ or $check eq "new"
+ or $check eq "old", "Error in parameters",
+ defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
+ defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
+ defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" );
+
+ NEW:
+ assert(
+ __LINE__,
+ ( not defined $check )
+ or ref $check
+ or $check eq "new"
+ or $check eq "old",
+ "Error in parameters",
+ defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
+ defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
+ defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef"
+ );
+
+ Another example shows how this helps displaying lists:
+
+ OLD:
+ %{ $self->{COMPONENTS} } = (
+ fname =>
+ { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
+ street =>
+ { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
+ );
+
+ The structure is clearer with the added indentation:
+
+ NEW:
+ %{ $self->{COMPONENTS} } = (
+ fname =>
+ { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
+ street =>
+ { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
+ );
+
+ -The structure of nested logical expressions is now displayed better.
+ Thanks to Wolfgang Weisselberg for helpful discussions. For example,
+ note how the status of the final 'or' is displayed in the following:
+
+ OLD:
+ return ( !null($op)
+ and null( $op->sibling )
+ and $op->ppaddr eq "pp_null"
+ and class($op) eq "UNOP"
+ and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/
+ and $op->first->first->sibling->ppaddr eq "pp_lineseq" )
+ or ( $op->first->ppaddr eq "pp_lineseq"
+ and not null $op->first->first->sibling
+ and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) );
+
+ NEW:
+ return (
+ !null($op)
+ and null( $op->sibling )
+ and $op->ppaddr eq "pp_null"
+ and class($op) eq "UNOP"
+ and (
+ (
+ $op->first->ppaddr =~ /^pp_(and|or)$/
+ and $op->first->first->sibling->ppaddr eq "pp_lineseq"
+ )
+ or ( $op->first->ppaddr eq "pp_lineseq"
+ and not null $op->first->first->sibling
+ and $op->first->first->sibling->ppaddr eq "pp_unstack" )
+ )
+ );
+
+ -A break will always be put before a list item containing a comma-arrow.
+ This will improve formatting of mixed lists of this form:
+
+ OLD:
+ $c->create(
+ 'text', 225, 20, -text => 'A Simple Plot',
+ -font => $font,
+ -fill => 'brown'
+ );
+
+ NEW:
+ $c->create(
+ 'text', 225, 20,
+ -text => 'A Simple Plot',
+ -font => $font,
+ -fill => 'brown'
+ );
+
+ -For convenience, the command -dac (--delete-all-comments) now also
+ deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod
+ to a '.TEE' file. Complete control over the treatment of pod and
+ comments is still possible, as described in the updated help message
+ and man page.
+
+ -The logic which breaks open 'containers' has been rewritten to be completely
+ symmetric in the following sense: if a line break is placed after an opening
+ {, [, or (, then a break will be placed before the corresponding closing
+ token. Thus, a container either remains closed or is completely cracked
+ open.
+
+ -Improved indentation of parenthesized lists. For example,
+
+ OLD:
+ $GPSCompCourse =
+ int(
+ atan2( $GPSTempCompLong - $GPSLongitude,
+ $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 );
+
+ NEW:
+ $GPSCompCourse = int(
+ atan2(
+ $GPSTempCompLong - $GPSLongitude,
+ $GPSLatitude - $GPSTempCompLat
+ ) * 180 / 3.14159265
+ );
+
+ Further improvements will be made in future releases.
+
+ -Some improvements were made in formatting small lists.
+
+ -Correspondence between Input and Output line numbers reported in a
+ .LOG file should now be exact. They were sometimes off due to the size
+ of intermediate buffers.
+
+ -Corrected minor tokenization error in which a ';' in a foreach loop
+ control was tokenized as a statement termination, which forced a
+ line break:
+
+ OLD:
+ foreach ( $i = 0;
+ $i <= 10;
+ $i += 2
+ )
+ {
+ print "$i ";
+ }
+
+ NEW:
+ foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) {
+ print "$i ";
+ }
+
+ -Corrected a problem with reading config files, in which quote marks were not
+ stripped. As a result, something like -wba="&& . || " would have the leading
+ quote attached to the && and not work correctly. A workaround for older
+ versions is to place a space around all tokens within the quotes, like this:
+ -wba=" && . || "
+
+ -Removed any existing space between a label and its ':'
+ OLD : { }
+ NEW: { }
+ This was necessary because the label and its colon are a single token.
+
+ -Corrected tokenization error for the following (highly non-recommended)
+ construct:
+ $user = @vars[1] / 100;
+
+ -Resolved cause of a difference between perltidy under perl v5.6.1 and
+ 5.005_03; the problem was different behavior of \G regex position
+ marker(!)
+
+## 2001 10 20
+
+ -Corrected a bug in which a break was not being made after a full-line
+ comment within a short eval/sort/map/grep block. A flag was not being
+ zeroed. The syntax error check catches this. Here is a snippet which
+ illustrates the bug:
+
+ eval {
+ #open Socket to Dispatcher
+ $sock = &OpenSocket;
+ };
+
+ The formatter mistakenly thought that it had found the following
+ one-line block:
+
+ eval {#open Socket to Dispatcher$sock = &OpenSocket; };
+
+ The patch fixes this. Many thanks to Henry Story for reporting this bug.
+
+ -Changes were made to help diagnose and resolve problems in a
+ .perltidyrc file:
+ (1) processing of command parameters has been into two separate
+ batches so that any errors in a .perltidyrc file can be localized.
+ (2) commands --help, --version, and as many of the --dump-xxx
+ commands are handled immediately, without any command line processing
+ at all.
+ (3) Perltidy will ignore any commands in the .perltidyrc file which
+ cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt
+ -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful
+ suggestions regarding these updates.
+
+ -Syntax check has been reinstated as default for MSWin32 systems. This
+ way Windows 2000 users will get syntax check by default, which seems
+ like a better idea, since the number of Win 95/98 systems will be
+ decreasing over time. Documentation revised to warn Windows 95/98
+ users about the problem with empty '&1'. Too bad these systems
+ all report themselves as MSWin32.
+
+## 2001 10 16
+
+ -Fixed tokenization error in which a method call of the form
+
+ Module::->new();
+
+ got a space before the '::' like this:
+
+ Module ::->new();
+
+ Thanks to David Holden for reporting this.
+
+ -Added -html control over pod text, using a new abbreviation 'pd'. See
+ updated perl2web man page. The default is to use the color of a comment,
+ but italicized. Old .css style sheets will need a new line for
+ .pd to use this. The old color was the color of a string, and there
+ was no control.
+
+ -.css lines are now printed in sorted order.
+
+ -Fixed interpolation problem where html files had '$input_file' as title
+ instead of actual input file name. Thanks to Simon Perreault for finding
+ this and sending a patch, and also to Tobias Weber.
+
+ -Breaks will now have the ':' placed at the start of a line,
+ one per line by default because this shows logical structure
+ more clearly. This coding has been completely redone. Some
+ examples of new ?/: formatting:
+
+ OLD:
+ wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) :
+ $dir::cwd->lookup( $_[0] )->path;
+
+ NEW:
+ wantarray
+ ? map( $dir::cwd->lookup($_)->path, @_ )
+ : $dir::cwd->lookup( $_[0] )->path;
+
+ OLD:
+ $a = ( $b > 0 ) ? {
+ a => 1,
+ b => 2
+ } : { a => 6, b => 8 };
+
+ NEW:
+ $a = ( $b > 0 )
+ ? {
+ a => 1,
+ b => 2
+ }
+ : { a => 6, b => 8 };
+
+ OLD: (-gnu):
+ $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" :
+ "Hunk #$self->{hunk} failed--$@");
+
+ NEW: (-gnu):
+ $self->note($self->{skip}
+ ? "Hunk #$self->{hunk} ignored at 1.\n"
+ : "Hunk #$self->{hunk} failed--$@");
+
+ OLD:
+ $which_search =
+ $opts{"t"} ? 'title' :
+ $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title';
+
+ NEW:
+ $which_search =
+ $opts{"t"} ? 'title'
+ : $opts{"s"} ? 'subject'
+ : $opts{"a"} ? 'author'
+ : 'title';
+
+ You can use -wba=':' to recover the previous default which placed ':'
+ at the end of a line. Thanks to Michael Cartmell for helpful
+ discussions and examples.
+
+ -Tokenizer updated to do syntax checking for matched ?/: pairs. Also,
+ the tokenizer now outputs a unique serial number for every balanced
+ pair of brace types and ?/: pairs. This greatly simplifies the
+ formatter.
+
+ -Long lines with repeated 'and', 'or', '&&', '||' will now have
+ one such item per line. For example:
+
+ OLD:
+ if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x
+ || ( -e $archive && $opt_r ) )
+ {
+ ( $pAr, $pNames ) = readAr($archive);
+ }
+
+ NEW:
+ if ( $opt_d
+ || $opt_m
+ || $opt_p
+ || $opt_t
+ || $opt_x
+ || ( -e $archive && $opt_r ) )
+ {
+ ( $pAr, $pNames ) = readAr($archive);
+ }
+
+ OLD:
+ if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x
+ && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y )
+
+ NEW:
+ if ( $vp->{X0} + 4 <= $x
+ && $vp->{X0} + $vp->{W} - 4 >= $x
+ && $vp->{Y0} + 4 <= $y
+ && $vp->{Y0} + $vp->{H} - 4 >= $y )
+
+ -Long lines with multiple concatenated tokens will have concatenated
+ terms (see below) placed one per line, except for short items. For
+ example:
+
+ OLD:
+ $report .=
+ "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:"
+ . $ib->crc . ": " . $ib->model() . "\n";
+
+ NEW:
+ $report .= "Device type:"
+ . $ib->family . " ID:"
+ . $ib->serial . " CRC:"
+ . $ib->model()
+ . $ib->crc . ": " . "\n";
+
+ NOTE: at present 'short' means 8 characters or less. There is a
+ tentative flag to change this (-scl), but it is undocumented and
+ is likely to be changed or removed later, so only use it for testing.
+ In the above example, the tokens " ID:", " CRC:", and "\n" are below
+ this limit.
+
+ -If a line which is short enough to fit on a single line was
+ nevertheless broken in the input file at a 'good' location (see below),
+ perltidy will try to retain a break. For example, the following line
+ will be formatted as:
+
+ open SUM, "<$file"
+ or die "Cannot open $file ($!)";
+
+ if it was broken in the input file, and like this if not:
+
+ open SUM, "<$file" or die "Cannot open $file ($!)";
+
+ GOOD: 'good' location means before 'and','or','if','unless','&&','||'
+
+ The reason perltidy does not just always break at these points is that if
+ there are multiple, similar statements, this would preclude alignment. So
+ rather than check for this, perltidy just tries to follow the input style,
+ in the hopes that the author made a good choice. Here is an example where
+ we might not want to break before each 'if':
+
+ ($Locale, @Locale) = ($English, @English) if (@English > @Locale);
+ ($Locale, @Locale) = ($German, @German) if (@German > @Locale);
+ ($Locale, @Locale) = ($French, @French) if (@French > @Locale);
+ ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale);
+
+ -Added wildcard file expansion for systems with shells which lack this.
+ Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers
+ for suggesting this. This uses builtin glob() for now; I may change that.
+
+ -Added new flag -sbl which, if specified, overrides the value of -bl
+ for opening sub braces. This allows formatting of this type:
+
+ perltidy -sbl
+
+ sub foo
+ {
+ if (!defined($_[0])) {
+ print("Hello, World\n");
+ }
+ else {
+ print($_[0], "\n");
+ }
+ }
+ Requested by Don Alexander.
+
+ -Fixed minor parsing error which prevented a space after a $$ variable
+ (pid) in some cases. Thanks to Michael Cartmell for noting this.
+ For example,
+ old: $$< 700
+ new: $$ < 700
+
+ -Improved line break choices 'and' and 'or' to display logic better.
+ For example:
+
+ OLD:
+ exists $self->{'build_dir'} and push @e,
+ "Unwrapped into directory $self->{'build_dir'}";
+
+ NEW:
+ exists $self->{'build_dir'}
+ and push @e, "Unwrapped into directory $self->{'build_dir'}";
+
+ -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains
+ abbreviation for delete-side-comments; -dsm is new abbreviation for
+ delete-semicolons.
+
+ -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for
+ noting an error.
+
+ -The default for Windows is, for now, not to do a 'perl -c' syntax
+ check (but -syn will activate it). This is because of problems with
+ command.com. James Freeman sent me a patch which tries to get around
+ the problems, and it works in many cases, but testing revealed several
+ issues that still need to be resolved. So for now, the default is no
+ syntax check for Windows.
+
+ -I added a -T flag when doing perl -c syntax check.
+ This is because I test it on a large number of scripts from sources
+ unknown, and who knows what might be hidden in initialization blocks?
+ Also, deactivated the syntax check if perltidy is run as root. As a
+ benign example, running the previous version of perltidy on the
+ following file would cause it to disappear:
+
+ BEGIN{
+ print "Bye, bye baby!\n";
+ unlink $0;
+ }
+
+ The new version will not let that happen.
+
+ -I am contemplating (but have not yet implemented) making '-lp' the
+ default indentation, because it is stable now and may be closer to how
+ perl is commonly formatted. This could be in the next release. The
+ reason that '-lp' was not the original default is that the coding for
+ it was complex and not ready for the initial release of perltidy. If
+ anyone has any strong feelings about this, I'd like to hear. The
+ current default could always be recovered with the '-nlp' flag.
+
+## 2001 09 03
+
+ -html updates:
+ - sub definition names are now specially colored, red by default.
+ The letter 'm' is used to identify them.
+ - keyword 'sub' now has color of other keywords.
+ - restored html keyword color to __END__ and __DATA__, which was
+ accidentally removed in the previous version.
+
+ -A new -se (--standard-error-output) flag has been implemented and
+ documented which causes all errors to be written to standard output
+ instead of a .ERR file.
+
+ -A new -w (--warning-output) flag has been implemented and documented
+ which causes perltidy to output certain non-critical messages to the
+ error output file, .ERR. These include complaints about pod usage,
+ for example. The default is to not include these.
+
+ NOTE: This replaces an undocumented -w=0 or --warning-level flag
+ which was tentatively introduced in the previous version to avoid some
+ unwanted messages. The new default is the same as the old -w=0, so
+ that is no longer needed.
+
+ -Improved syntax checking and corrected tokenization of functions such
+ as rand, srand, sqrt, ... These can accept either an operator or a term
+ to their right. This has been corrected.
+
+ -Corrected tokenization of semicolon: testing of the previous update showed
+ that the semicolon in the following statement was being mis-tokenized. That
+ did no harm, other than adding an extra blank space, but has been corrected.
+
+ for (sort {strcoll($a,$b);} keys %investments) {
+ ...
+ }
+
+ -New syntax check: after wasting 5 minutes trying to resolve a syntax
+ error in which I had an extra terminal ';' in a complex for (;;) statement,
+ I spent a few more minutes adding a check for this in perltidy so it won't
+ happen again.
+
+ -The behavior of --break-before-subs (-bbs) and --break-before-blocks
+ (-bbb) has been modified. Also, a new control parameter,
+ --long-block-line-count=n (-lbl=n) has been introduced to give more
+ control on -bbb. This was previously a hardwired value. The reason
+ for the change is to reduce the number of unwanted blank lines that
+ perltidy introduces, and make it less erratic. It's annoying to remove
+ an unwanted blank line and have perltidy put it back. The goal is to
+ be able to sprinkle a few blank lines in that dense script you
+ inherited from Bubba. I did a lot of experimenting with different
+ schemes for introducing blank lines before and after code blocks, and
+ decided that there is no really good way to do it. But I think the new
+ scheme is an improvement. You can always deactivate this with -nbbb.
+ I've been meaning to work on this; thanks to Erik Thaysen for bringing
+ it to my attention.
+
+ -The .LOG file is seldom needed, and I get tired of deleting them, so
+ they will now only be automatically saved if perltidy thinks that it
+ made an error, which is almost never. You can still force the logfile
+ to be saved with -log or -g.
+
+ -Improved method for computing number of columns in a table. The old
+ method always tried for an even number. The new method allows odd
+ numbers when it is obvious that a list is not a hash initialization
+ list.
+
+ old: my (
+ $name, $xsargs, $parobjs, $optypes,
+ $hasp2child, $pmcode, $hdrcode, $inplacecode,
+ $globalnew, $callcopy
+ )
+ = @_;
+
+ new: my (
+ $name, $xsargs, $parobjs, $optypes, $hasp2child,
+ $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy
+ )
+ = @_;
+
+ -I fiddled with the list threshold adjustment, and some small lists
+ look better now. Here is the change for one of the lists in test file
+ 'sparse.t':
+ old:
+ %units =
+ ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%",
+ "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%");
+
+ new:
+ %units = (
+ "in", "in", "pt", "pt", "pc", "pi",
+ "mm", "mm", "cm", "cm", "\\hsize", "%",
+ "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"
+ );
+
+ -Improved -lp formatting at '=' sign. A break was always being added after
+ the '=' sign in a statement such as this, (to be sure there was enough room
+ for the parameters):
+
+ old: my $fee =
+ CalcReserveFee(
+ $env, $borrnum,
+ $biblionumber, $constraint,
+ $bibitems
+ );
+
+ The updated version doesn't do this unless the space is really needed:
+
+ new: my $fee = CalcReserveFee(
+ $env, $borrnum,
+ $biblionumber, $constraint,
+ $bibitems
+ );
+
+ -I updated the tokenizer to allow $#+ and $#-, which seem to be new to
+ Perl 5.6. Some experimenting with a recent version of Perl indicated
+ that it allows these non-alphanumeric '$#' array maximum index
+ varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#:
+ seems to be valid in older versions of Perl.
+
+ -Fixed a rare formatting problem with -lp (and -gnu) which caused
+ excessive indentation.
+
+ -Many additional syntax checks have been added.
+
+ -Revised method for testing here-doc target strings; the following
+ was causing trouble with a regex test because of the '*' characters:
+ print <<"*EOF*";
+ bla bla
+ *EOF*
+ Perl seems to allow almost anything to be a here doc target, so an
+ exact string comparison is now used.
+
+ -Made update to allow underscores in binary numbers, like '0b1100_0000'.
+
+ -Corrected problem with scanning certain module names; a blank space was
+ being inserted after 'warnings' in the following:
+ use warnings::register;
+ The problem was that warnings (and a couple of other key modules) were
+ being tokenized as keywords. They should have just been identifiers.
+
+ -Corrected tokenization of indirect objects after sort, system, and exec,
+ after testing produced an incorrect error message for the following
+ line of code:
+ print sort $sortsubref @list;
+
+ -Corrected minor problem where a line after a format had unwanted
+ extra continuation indentation.
+
+ -Delete-block-comments (and -dac) now retain any leading hash-bang line
+
+ -Update for -lp (and -gnu) to not align the leading '=' of a list
+ with a previous '=', since this interferes with alignment of parameters.
+
+ old: my $hireDay = new Date;
+ my $self = {
+ firstName => undef,
+ lastName => undef,
+ hireDay => $hireDay
+ };
+
+ new: my $hireDay = new Date;
+ my $self = {
+ firstName => undef,
+ lastName => undef,
+ hireDay => $hireDay
+ };
+
+ -Modifications made to display tables more compactly when possible,
+ without adding lines. For example,
+ old:
+ '1', "I", '2', "II", '3', "III", '4', "IV",
+ '5', "V", '6', "VI", '7', "VII", '8', "VIII",
+ '9', "IX"
+ new:
+ '1', "I", '2', "II", '3', "III",
+ '4', "IV", '5', "V", '6', "VI",
+ '7', "VII", '8', "VIII", '9', "IX"
+
+ -Corrected minor bug in which -pt=2 did not keep the right paren tight
+ around a '++' or '--' token, like this:
+
+ for ($i = 0 ; $i < length $key ; $i++ )
+
+ The formatting for this should be, and now is:
+
+ for ($i = 0 ; $i < length $key ; $i++)
+
+ Thanks to Erik Thaysen for noting this.
+
+ -Discovered a new bug involving here-docs during testing! See BUGS.html.
+
+ -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature).
+ However, the attributes and prototypes must still be on the same line
+ as the sub name.
+
+## 2001 07 31
+
+ -Corrected minor, uncommon bug found during routine testing, in which a
+ blank got inserted between a function name and its opening paren after
+ a file test operator, but only in the case that the function had not
+ been previously seen. Perl uses the existence (or lack thereof) of
+ the blank to guess if it is a function call. That is,
+ if (-l pid_filename()) {
+ became
+ if (-l pid_filename ()) {
+ which is a syntax error if pid_filename has not been seen by perl.
+
+ -If the AutoLoader module is used, perltidy will continue formatting
+ code after seeing an __END__ line. Use -nlal to deactivate this feature.
+ Likewise, if the SelfLoader module is used, perltidy will continue
+ formatting code after seeing a __DATA__ line. Use -nlsl to
+ deactivate this feature. Thanks to Slaven Rezic for this suggestion.
+
+ -pod text after __END__ and __DATA__ is now identified by perltidy
+ so that -dp works correctly. Thanks to Slaven Rezic for this suggestion.
+
+ -The first $VERSION line which might be eval'd by MakeMaker
+ is now passed through unchanged. Use -npvl to deactivate this feature.
+ Thanks to Manfred Winter for this suggestion.
+
+ -Improved indentation of nested parenthesized expressions. Tests have
+ given favorable results. Thanks to Wolfgang Weisselberg for helpful
+ examples.
+
+## 2001 07 23
+
+ -Fixed a very rare problem in which an unwanted semicolon was inserted
+ due to misidentification of anonymous hash reference curly as a code
+ block curly. (No instances of this have been reported; I discovered it
+ during testing). A workaround for older versions of perltidy is to use
+ -nasc.
+
+ -Added -icb (-indent-closing-brace) parameter to indent a brace which
+ terminates a code block to the same level as the previous line.
+ Suggested by Andrew Cutler. For example,
+
+ if ($task) {
+ yyy();
+ } # -icb
+ else {
+ zzz();
+ }
+
+ -Rewrote error message triggered by an unknown bareword in a print or
+ printf filehandle position, and added flag -w=0 to prevent issuing this
+ error message. Suggested by Byron Jones.
+
+ -Added modification to align a one-line 'if' block with similar
+ following 'elsif' one-line blocks, like this:
+ if ( $something eq "simple" ) { &handle_simple }
+ elsif ( $something eq "hard" ) { &handle_hard }
+ (Suggested by Wolfgang Weisselberg).
+
+## 2001 07 02
+
+ -Eliminated all constants with leading underscores because perl 5.005_03
+ does not support that. For example, _SPACES changed to XX_SPACES.
+ Thanks to kromJx for this update.
+
+## 2001 07 01
+
+ -the directory of test files has been moved to a separate distribution
+ file because it is getting large but is of little interest to most users.
+ For the current distribution:
+ perltidy-20010701.tgz contains the source and docs for perltidy
+ perltidy-20010701-test.tgz contains the test files
+
+ -fixed bug where temporary file perltidy.TMPI was not being deleted
+ when input was from stdin.
+
+ -adjusted line break logic to not break after closing brace of an
+ eval block (suggested by Boris Zentner).
+
+ -added flag -gnu (--gnu-style) to give an approximation to the GNU
+ style as sometimes applied to perl. The programming style in GNU
+ 'automake' was used as a guide in setting the parameters; these
+ parameters will probably be adjusted over time.
+
+ -an empty code block now has one space for emphasis:
+ if ( $cmd eq "bg_untested" ) {} # old
+ if ( $cmd eq "bg_untested" ) { } # new
+ If this bothers anyone, we could create a parameter.
+
+ -the -bt (--brace-tightness) parameter has been split into two
+ parameters to give more control. -bt now applies only to non-BLOCK
+ braces, while a new parameter -bbt (block-brace-tightness) applies to
+ curly braces which contain code BLOCKS. The default value is -bbt=0.
+
+ -added flag -icp (--indent-closing-paren) which leaves a statement
+ termination of the form );, };, or ]; indented with the same
+ indentation as the previous line. For example,
+
+ @month_of_year = ( # default, or -nicp
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+ 'Nov', 'Dec'
+ );
+
+ @month_of_year = ( # -icp
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+ 'Nov', 'Dec'
+ );
+
+ -Vertical alignment updated to synchronize with tokens &&, ||,
+ and, or, if, unless. Allowable space before forcing
+ resynchronization has been increased. (Suggested by Wolfgang
+ Weisselberg).
+
+ -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold,
+ and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There
+ was no way to negate these previously. html documentation updated and
+ corrected. (Suggested by Wolfgang Weisselberg).
+
+ -Some modifications have been made which improve the -lp formatting in
+ a few cases.
+
+ -Perltidy now retains or creates a blank line after an =cut to keep
+ podchecker happy (Suggested by Manfred H. Winter). This appears to be
+ a glitch in podchecker, but it was annoying.
+
+## 2001 06 17
+
+ -Added -bli flag to give continuation indentation to braces, like this
+
+ if ($bli_flag)
+ {
+ extra_indentation();
+ }
+
+ -Corrected an error with the tab (-t) option which caused the last line
+ of a multi-line quote to receive a leading tab. This error was in
+ version 2001 06 08 but not 2001 04 06. If you formatted a script
+ with -t with this version, please check it by running once with the
+ -chk flag and perltidy will scan for this possible error.
+
+ -Corrected an invalid pattern (\R should have been just R), changed
+ $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected
+ several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg,
+ 2001-06-12, for catching these errors.
+
+ -A '-bar' flag has been added to require braces to always be on the
+ right, even for multi-line if and foreach statements. For example,
+ the default formatting of a long if statement would be:
+
+ if ($bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4)
+ {
+ bigwastoftime();
+ }
+
+ With -bar, the formatting is:
+
+ if ($bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4) {
+ bigwastoftime();
+ }
+ Suggested by Eli Fidler 2001-06-11.
+
+ -Uploaded perltidy to sourceforge cvs 2001-06-10.
+
+ -An '-lp' flag (--line-up-parentheses) has been added which causes lists
+ to be indented with extra indentation in the manner sometimes
+ associated with emacs or the GNU suggestions. Thanks to Ian Stuart for
+ this suggestion and for extensive help in testing it.
+
+ -Subroutine call parameter lists are now formatted as other lists.
+ This should improve formatting of tables being passed via subroutine
+ calls. This will also cause full indentation ('-i=n, default n= 4) of
+ continued parameter list lines rather than just the number of spaces
+ given with -ci=n, default n=2.
+
+ -Added support for hanging side comments. Perltidy identifies a hanging
+ side comment as a comment immediately following a line with a side
+ comment or another hanging side comment. This should work in most
+ cases. It can be deactivated with --no-hanging-side-comments (-nhsc).
+ The manual has been updated to discuss this. Suggested by Brad
+ Eisenberg some time ago, and finally implemented.
+
+## 2001 06 08
+
+ -fixed problem with parsing command parameters containing quoted
+ strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07).
+
+ -added two command line flags, --want-break-after and
+ --want-break-before, which allow changing whether perltidy
+ breaks lines before or after any operators. Please see the revised
+ man pages for details.
+
+ -added system-wide configuration file capability.
+ If perltidy does not find a .perltidyrc command line file in
+ the current directory, nor in the home directory, it now looks
+ for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'.
+ (Suggested by Roger Espel Llima 2001-05-31).
+
+ -fixed problem in which spaces were trimmed from lines of a multi-line
+ quote. (Reported by Roger Espel Llima 2001-05-30). This is an
+ uncommon situation, but serious, because it could conceivably change
+ the proper function of a script.
+
+ -fixed problem in which a semicolon was incorrectly added within
+ an anonymous hash. (Reported by A.C. Yardley, 2001-5-23).
+ (You would know if this happened, because perl would give a syntax
+ error for the resulting script).
+
+ -fixed problem in which an incorrect error message was produced
+ after a version number on a 'use' line, like this ( Reported
+ by Andres Kroonmaa, 2001-5-14):
+
+ use CGI 2.42 qw(fatalsToBrowser);
+
+ Other than the extraneous error message, this bug was harmless.
+
+## 2001 04 06
+
+ -fixed serious bug in which the last line of some multi-line quotes or
+ patterns was given continuation indentation spaces. This may make
+ a pattern incorrect unless it uses the /x modifier. To find
+ instances of this error in scripts which have been formatted with
+ earlier versions of perltidy, run with the -chk flag, which has
+ been added for this purpose (SLH, 2001-04-05).
+
+ ** So, please check previously formatted scripts by running with -chk
+ at least once **
+
+ -continuation indentation has been reprogrammed to be hierarchical,
+ which improves deeply nested structures.
+
+ -fixed problem with undefined value in list formatting (reported by Michael
+ Langner 2001-04-05)
+
+ -Switched to graphical display of nesting in .LOG files. If an
+ old format string was "(1 [0 {2", the new string is "{{(". This
+ is easier to read and also shows the order of nesting.
+
+ -added outdenting of cuddled paren structures, like ")->pack(".
+
+ -added line break and outdenting of ')->' so that instead of
+
+ $mw->Label(
+ -text => "perltidy",
+ -relief => 'ridge')->pack;
+
+ the current default is:
+
+ $mw->Label(
+ -text => "perltidy",
+ -relief => 'ridge'
+ )->pack;
+
+ (requested by Michael Langner 2001-03-31; in the future this could
+ be controlled by a command-line parameter).
+
+ -revised list indentation logic, so that lists following an assignment
+ operator get one full indentation level, rather than just continuation
+ indentation. Also corrected some minor glitches in the continuation
+ indentation logic.
+
+ -Fixed problem with unwanted continuation indentation after a blank line
+ (reported by Erik Thaysen 2001-03-28):
+
+ -minor update to avoid stranding a single '(' on one line
+
+## 2001 03 28:
+
+ -corrected serious error tokenizing filehandles, in which a sub call
+ after a print or printf, like this:
+ print usage() and exit;
+ became this:
+ print usage () and exit;
+ Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun
+ perltidy; it will look for this situation and issue a warning.
+
+ -fixed another cuddled-else formatting bug (Reported by Craig Bourne)
+
+ -added several diagnostic --dump routines
+
+ -added token-level whitespace controls (suggested by Hans Ecke)
+
+## 2001 03 23:
+
+ -added support for special variables of the form ${^WANT_BITS}
+
+ -space added between scalar and left paren in 'for' and 'foreach' loops,
+ (suggestion by Michael Cartmell):
+
+ for $i( 1 .. 20 ) # old
+ for $i ( 1 .. 20 ) # new
+
+ -html now outputs cascading style sheets (thanks to suggestion from
+ Hans Ecke)
+
+ -flags -o and -st now work with -html
+
+ -added missing -html documentation for comments (noted by Alex Izvorski)
+
+ -support for VMS added (thanks to Michael Cartmell for code patches and
+ testing)
+
+ -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive
+ testing by Michael Cartmell)
+
+ -fixed problem where operand may be empty at line 3970
+ (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen,
+ Keith Marshall for bug reports)
+
+ -fixed -ce bug (cuddled else), where lines like '} else {' were indented
+ (Thanks to Shawn Stepper and Rick Measham for reporting this)
+
+## 2001 03 04:
+
+ -fixed undefined value in line 153 (only worked with -I set)
+ (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others)
+
+ -fixed undefined value in line 1069 (filehandle problem with perl versions <
+ 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber)
+
+## 2001 03 03:
+
+ -Initial announcement at freshmeat.net; started Change Log
+ (Unfortunately this version was DOA, but it was fixed the next day)
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#PERLTIDY-INSTALLATION-NOTES">PERLTIDY INSTALLATION NOTES</a></li>
- <li><a href="#Get-a-distribution-file">Get a distribution file</a></li>
- <li><a href="#Quick-Test-Drive">Quick Test Drive</a></li>
- <li><a href="#Uninstall-older-versions">Uninstall older versions</a></li>
- <li><a href="#Two-Installation-Methods---Overview">Two Installation Methods - Overview</a>
- <ul>
- <li><a href="#Unix-Installation-Notes">Unix Installation Notes</a></li>
- <li><a href="#Windows-Installation-Notes">Windows Installation Notes</a></li>
- <li><a href="#VMS-Installation-Notes">VMS Installation Notes</a></li>
- </ul>
- </li>
- <li><a href="#Troubleshooting-Other-Operating-Systems">Troubleshooting / Other Operating Systems</a></li>
- <li><a href="#CONFIGURATION-FILE">CONFIGURATION FILE</a></li>
- <li><a href="#SYSTEM-TEMPORARY-FILES">SYSTEM TEMPORARY FILES</a></li>
- <li><a href="#DOCUMENTATION">DOCUMENTATION</a></li>
- <li><a href="#CREDITS">CREDITS</a></li>
- <li><a href="#FEEDBACK-BUG-REPORTS">FEEDBACK / BUG REPORTS</a></li>
-</ul>
-
-<h1 id="PERLTIDY-INSTALLATION-NOTES">PERLTIDY INSTALLATION NOTES</h1>
-
-<h1 id="Get-a-distribution-file">Get a distribution file</h1>
-
-<dl>
-
-<dt id="Source-Files-in-.tar.gz-and-.zip-format">Source Files in .tar.gz and .zip format</dt>
-<dd>
-
-<p>This document tells how to install perltidy from the basic source distribution files in <i>.tar.gz</i> or <i>.zip</i> format. These files are identical except for the line endings. The <i>.tar.gz</i> has Unix style line endings, and the <i>.zip</i> file has Windows style line endings. The standard perl MakeMaker method should work for these in most cases.</p>
-
-</dd>
-<dt id="Source-files-in-RPM-and-.deb-format">Source files in RPM and .deb format</dt>
-<dd>
-
-<p>The web site also has links to RPM and Debian .deb Linux packages, which may be convenient for some users.</p>
-
-</dd>
-</dl>
-
-<h1 id="Quick-Test-Drive">Quick Test Drive</h1>
-
-<p>If you want to do a quick test of perltidy without doing any installation, get a <i>.tar.gz</i> or a <i>.zip</i> source file and see the section below "Method 2: Installation as a single binary script".</p>
-
-<h1 id="Uninstall-older-versions">Uninstall older versions</h1>
-
-<p>In certain circumstances, it is best to remove an older version of perltidy before installing the latest version. These are:</p>
-
-<dl>
-
-<dt id="Uninstall-a-Version-older-than-20020225">Uninstall a Version older than 20020225</dt>
-<dd>
-
-<p>You can use perltidy -v to determine the version number. The first version of perltidy to use Makefile.PL for installation was 20020225, so if your previous installation is older than this, it is best to remove it, because the installation path may now be different. There were up to 3 files these older installations: the script <i>perltidy</i> and possibly two man pages, <i>perltidy.1</i> and <i>perl2web.1</i>. If you saved your Makefile, you can probably use <code>make uninstall</code>. Otherwise, you can use a <i>locate</i> or <i>find</i> command to find and remove these files.</p>
-
-</dd>
-<dt id="Uninstall-older-versions-when-changing-installation-method">Uninstall older versions when changing installation method</dt>
-<dd>
-
-<p>If you switch from one installation method to another, the paths to the components of perltidy may change, so it is probably best to remove the older version before installing the new version. If your older installation method had an uninstall option (such as with RPM's and debian packages), use it. Otherwise, you can locate and remove the older files by hand. There are two key files: <i>Tidy.pm</i> and <i>perltidy</i>. In addition, there may be one or two man pages, something like <i>Perl::Tidy.3pm</i> and <i>perltidy.1p</i>. You can use a <code>locate</code> and/or <code>find</code> command to find and remove these files. After installation, you can verify that the new version of perltidy is working with the <code>perltidy -v</code> command.</p>
-
-</dd>
-</dl>
-
-<h1 id="Two-Installation-Methods---Overview">Two Installation Methods - Overview</h1>
-
-<p>These are generic instructions. Some system-specific notes and hints are given in later sections.</p>
-
-<p>Two separate installation methods are possible.</p>
-
-<dl>
-
-<dt id="Method-1:-Standard-Installation-Method">Method 1: Standard Installation Method</dt>
-<dd>
-
-<p>The standard method based on MakeMaker should work in a normal perl environment. This is the recommended installation procedure for systems which support it.</p>
-
-<pre><code> perl Makefile.PL
- make
- make test
- make install</code></pre>
-
-<p>The <code>make</code> command is probably <code>nmake</code> under a Windows system. You may need to become root (or administrator) before doing the <code>make install</code> step.</p>
-
-</dd>
-<dt id="Method-2:-Installation-as-a-single-binary-script">Method 2: Installation as a single binary script</dt>
-<dd>
-
-<p>If you just want to take perltidy for a quick test drive without installing it, or are having trouble installing modules, you can bundle it all in one independent executable script. This might also be helpful on a system for which the Makefile.PL method does not work, or if you are temporarily a guest on some system, or if you want to try hacking a special version of perltidy without messing up your regular version.</p>
-
-<p>You just need to uncompress the source distribution, cd down into it, and enter the command:</p>
-
-<pre><code> perl pm2pl</code></pre>
-
-<p>which will combine the pieces of perltidy into a single script named <i>perltidy</i> in the current directory. This script should be fully functional. Try it out on a handy perl script, for example</p>
-
-<pre><code> perl perltidy Makefile.PL</code></pre>
-
-<p>This should create <i>Makefile.PL.tdy</i>.</p>
-
-</dd>
-<dt id="After-Installation">After Installation</dt>
-<dd>
-
-<p>After installation by either method, verify that the installation worked and that the correct new version is being by entering:</p>
-
-<pre><code> perltidy -v</code></pre>
-
-<p>If the version number disagrees with the version number embedded in the distribution file name, search for and remove the old version. For example, under a Unix system, the command <code>which perltidy</code> might show where it is. Also, see the above notes on uninstalling older versions.</p>
-
-<p>On a Unix system running the <code>bash</code> shell, if you had a previous installation of perltidy, you may have to use</p>
-
-<pre><code> hash -r</code></pre>
-
-<p>to get the shell to find the new one.</p>
-
-<p>After <i>perltidy</i> is installed, you can find where it will look for configuration files and environment variables on your system with the command:</p>
-
-<pre><code> perltidy -dpro</code></pre>
-
-</dd>
-<dt id="How-to-Uninstall">How to Uninstall</dt>
-<dd>
-
-<p>Unfortunately, the standard Perl installation method does not seem able to do an uninstall.</p>
-
-<p>But try this:</p>
-
-<pre><code> make uninstall</code></pre>
-
-<p>On some systems, it will give you a list of files to remove by hand. If not, you need to find the script <i>perltidy</i> and its module file <i>Tidy.pm</i>, which will be in a subdirectory named <i>Perl</i> in the site library.</p>
-
-<p>If you installed perltidy with the alternative method, you should just reverse the steps that you used.</p>
-
-</dd>
-</dl>
-
-<h2 id="Unix-Installation-Notes">Unix Installation Notes</h2>
-
-<dl>
-
-<dt id="Alternative-method---Unix">Alternative method - Unix</dt>
-<dd>
-
-<p>If the alternative method is used, test the script produced by the <code>pm2pl</code> perl script:</p>
-
-<pre><code> perl ./perltidy somefile.pl</code></pre>
-
-<p>where <i>somefile.pl</i> is any convenient test file, such as <i>Makefile.PL</i> itself. Then,</p>
-
-<p>1. If the script is not executable, use</p>
-
-<pre><code> chmod +x perltidy</code></pre>
-
-<p>2. Verify that the initial line in perltidy works for your system by entering:</p>
-
-<pre><code> ./perltidy -h</code></pre>
-
-<p>which should produce the usage text and then exit. This should usually work, but if it does not, you will need to change the first line in <i>perltidy</i> to reflect the location of perl on your system. On a Unix system, you might find the path to perl with the command 'which perl'.</p>
-
-<p>3. A sample <i>Makefile</i> for this installation method is <i>Makefile.npm</i>. Edit it to have the correct paths.</p>
-
-<p>You will need to become root unless you change the paths to point to somewhere in your home directory. Then issue the command</p>
-
-<pre><code> make -f Makefile.npm install</code></pre>
-
-<p>This installs perltidy and the man page perltidy.1.</p>
-
-<p>5. Test the installation using</p>
-
-<pre><code> perltidy -h</code></pre>
-
-<p>You should see the usage screen. Then, if you installed the man pages, try</p>
-
-<pre><code> man perltidy</code></pre>
-
-<p>which should bring up the manual page.</p>
-
-<p>If you ever want to remove perltidy, you can remove perltidy and its man pages by hand or use</p>
-
-<pre><code> make uninstall</code></pre>
-
-</dd>
-</dl>
-
-<h2 id="Windows-Installation-Notes">Windows Installation Notes</h2>
-
-<p>On a Windows 9x/Me system you should CLOSE ANY OPEN APPLICATIONS to avoid losing unsaved data in case of trouble.</p>
-
-<dl>
-
-<dt id="Standard-Method---Windows">Standard Method - Windows</dt>
-<dd>
-
-<p>After you unzip the distribution file, the procedure is probably this:</p>
-
-<pre><code> perl Makefile.PL
- nmake
- nmake test
- nmake install</code></pre>
-
-<p>You may need to download a copy of <i>unzip</i> to unzip the <i>.zip</i> distribution file; you can get this at http://www.info-zip.org/pub/infozip/UnZip.html</p>
-
-<p>If you have ActiveState Perl, the installation method is outlined at http://aspn.activestate.com//ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq9.html#How_can_I_use_modules_from_CPAN_</p>
-
-<p>You may need to download a copy of Microsoft's <i>nmake</i> program from ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe</p>
-
-<p>If you are not familiar with installing modules, or have trouble doing so, and want to start testing perltidy quickly, you may want to use the alternative method instead (next section).</p>
-
-</dd>
-<dt id="Alternative-Method---Windows">Alternative Method - Windows</dt>
-<dd>
-
-<p>From the main installation directory, just enter</p>
-
-<pre><code> perl pm2pl </code></pre>
-
-<p>Placing the resulting file <i>perltidy</i> and the example batch file <i>perltidy.bat</i>, located in the <i>examples</i> directory, in your path should work. (You can determine your path by issuing the msdos command <code>PATH</code>). However, the batch file probably will not support file redirection. So, for example, to pipe the long help message through 'more', you might have to invoke perltidy with perl directly, like this:</p>
-
-<pre><code> perl \somepath\perltidy -h | more</code></pre>
-
-<p>The batch file will not work properly with wildcard filenames, but you may use wildcard filenames if you place them in quotes. For example</p>
-
-<pre><code> perltidy '*.pl'</code></pre>
-
-</dd>
-</dl>
-
-<h2 id="VMS-Installation-Notes">VMS Installation Notes</h2>
-
-<dl>
-
-<dt id="Links-to-VMS-Utilities-and-Documentation">Links to VMS Utilities and Documentation</dt>
-<dd>
-
-<p>To install perltidy you will need the following utilities Perl, of course, source with VMS goodies available from http://www.sidhe.org/vmsperl or binary available from the Compaq OpenVMS freeware CD. To unpack the source either gunzip and vmstar available from the Compaq OpenVMS freeware CD or zip available from http://www.info-zip.org/</p>
-
-<p>To build perltidy you can use either <b>MMS</b>, Compaq's VMS equivalent of make, or <b>MMK</b>, an <b>MMS</b> clone available from http://www.madgoat.com.</p>
-
-<p>Information on running perl under VMS can be found at: http://w4.lns.cornell.edu/~pvhp/perl/VMS.html</p>
-
-</dd>
-<dt id="Unpack-the-source">Unpack the source:</dt>
-<dd>
-
-<pre><code> $ unzip -a perl-tidy-yyyymmdd.zip ! or
-
- $ unzip /text=auto perl-tidy-yyyymmdd.zip ! or
-
- $ gunzip perl-tidy-yyyymmdd.tgz
- $ vmstar perl-tidy-yyyymmdd.tar</code></pre>
-
-</dd>
-<dt id="Build-and-install-perltidy-under-VMS">Build and install perltidy under VMS:</dt>
-<dd>
-
-<pre><code> $ set default [.perl-tidy-yyymmdd]
- $ perl perltidy.pl
- $ mmk
- $ mmk test
- $ mmk install</code></pre>
-
-</dd>
-<dt id="Using-Perltidy-under-VMS">Using Perltidy under VMS</dt>
-<dd>
-
-<p>Create a symbol. This should be put in a logon script, eg sylogin.com</p>
-
-<pre><code> $ perltidy == "perl perl_root:[utils]perltidy."</code></pre>
-
-<p>Default parameters can be placed in a <i>perltidyrc</i> file. Perltidy looks for one in the following places and uses the first found if the logical <code>PERLTIDY</code> is a file and the file exists then that is used if the logical <code>PERLTIDY</code> is a directory then look for a <i>.perltidyrc</i> file in the directory look for a <i>.perltidyrc</i> file in the user's home directory</p>
-
-<p>To see where the search is done and which <i>.perltidyrc</i> is used type</p>
-
-<pre><code> $ perltidy -dpro</code></pre>
-
-<p>A system <code>PERLTIDY</code> logical can be defined pointing to a file with a minimal configuration, and users can defined their own logical to use a personal <i>.perltidyrc</i> file.</p>
-
-<pre><code> $ define /system perltidy perl_root:[utils]perltidy.rc</code></pre>
-
-</dd>
-<dt id="The--x-Parameter">The -x Parameter</dt>
-<dd>
-
-<p>If you have one of the magic incantations at the start of perl scripts, so that they can be invoked as a .com file, then you will need to use the <b>-x</b> parameter which causes perltidy to skip all lines until it finds a hash bang line eg <code>#!perl -w</code>. Since it is such a common option this is probably a good thing to put in a <i>.perltidyrc</i> file.</p>
-
-</dd>
-<dt id="VMS-File-Extensions">VMS File Extensions</dt>
-<dd>
-
-<p>VMS file extensions will use an underscore character instead of a dot, when necessary, to create a valid filename. So</p>
-
-<pre><code> perltidy myfile.pl</code></pre>
-
-<p>will generate the output file <i>myfile.pl_tdy</i> instead of <i>myfile.pl.tdy</i>, and so on.</p>
-
-</dd>
-</dl>
-
-<h1 id="Troubleshooting-Other-Operating-Systems">Troubleshooting / Other Operating Systems</h1>
-
-<p>If there seems to be a problem locating a configuration file, you can see what is going on in the config file search with:</p>
-
-<pre><code> perltidy -dpro</code></pre>
-
-<p>If you want to customize where perltidy looks for configuration files, look at the routine 'find_config_file' in module 'Tidy.pm'. You should be able to at least use the '-pro=filename' method under most systems.</p>
-
-<p>Remember to place quotes (either single or double) around input parameters which contain spaces, such as file names. For example:</p>
-
-<pre><code> perltidy "file name with spaces"</code></pre>
-
-<p>Without the quotes, perltidy would look for four files: <i>file</i>, <i>name</i>, <i>with</i>, and <i>spaces</i>.</p>
-
-<p>If you develop a system-dependent patch that might be of general interest, please let us know.</p>
-
-<h1 id="CONFIGURATION-FILE">CONFIGURATION FILE</h1>
-
-<p>You do not need a configuration file, but you may eventually want to create one to save typing; the tutorial and man page discuss this.</p>
-
-<h1 id="SYSTEM-TEMPORARY-FILES">SYSTEM TEMPORARY FILES</h1>
-
-<p>Perltidy needs to create a system temporary file when it invokes Pod::Html to format pod text under the -html option. For Unix systems, this will normally be a file in /tmp, and for other systems, it will be a file in the current working directory named <i>perltidy.TMP</i>. This file will be removed when the run finishes.</p>
-
-<h1 id="DOCUMENTATION">DOCUMENTATION</h1>
-
-<p>Documentation is contained in <b>.pod</b> format, either in the <i>docs</i> directory or appended to the scripts.</p>
-
-<p>These documents can also be found at http://perltidy.sourceforge.net</p>
-
-<p>Reading the brief tutorial should help you use perltidy effectively. The tutorial can be read interactively with <b>perldoc</b>, for example</p>
-
-<pre><code> cd docs
- perldoc tutorial.pod</code></pre>
-
-<p>or else an <i>html</i> version can be made with <b>pod2html</b>:</p>
-
-<pre><code> pod2html tutorial.pod >tutorial.html</code></pre>
-
-<p>If you use the Makefile.PL installation method on a Unix system, the <b>perltidy</b> and <b>Perl::Tidy</b> man pages should automatically be installed. Otherwise, you can extract the man pages with the <b>pod2xxxx</b> utilities, as follows:</p>
-
-<pre><code> cd bin
- pod2text perltidy >perltidy.txt
- pod2html perltidy >perltidy.html
-
- cd lib/Perl
- pod2text Tidy.pm >Tidy.txt
- pod2html Tidy.pm >Tidy.html</code></pre>
-
-<p>After installation, the installation directory of files may be deleted.</p>
-
-<p>Perltidy is still being developed, so please check sourceforge occasionally for updates if you find that it is useful. New releases are announced on freshmeat.net.</p>
-
-<h1 id="CREDITS">CREDITS</h1>
-
-<p>Thanks to the many programmers who have documented problems, made suggestions and sent patches.</p>
-
-<h1 id="FEEDBACK-BUG-REPORTS">FEEDBACK / BUG REPORTS</h1>
-
-<p>If you see ways to improve these notes, please let us know.</p>
-
-<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>
-
-<p>To report a new bug or problem, use the link on this page .</p>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# PERLTIDY INSTALLATION NOTES
+
+# Get a distribution file
+
+- Source Files in .tar.gz and .zip format
+
+ This document tells how to install perltidy from the basic source
+ distribution files in `.tar.gz` or `.zip` format. These files are
+ identical except for the line endings. The `.tar.gz` has Unix style
+ line endings, and the `.zip` file has Windows style line endings. The
+ standard perl MakeMaker method should work for these in most cases.
+
+- Source files in RPM and .deb format
+
+ The web site also has links to RPM and Debian .deb Linux packages, which may be
+ convenient for some users.
+
+# Quick Test Drive
+
+If you want to do a quick test of perltidy without doing any installation, get
+a `.tar.gz` or a `.zip` source file and see the section below "Method 2: Installation
+as a single binary script".
+
+# Uninstall older versions
+
+In certain circumstances, it is best to remove an older version
+of perltidy before installing the latest version. These are:
+
+- Uninstall a Version older than 20020225
+
+ You can use perltidy -v to determine the version number. The first
+ version of perltidy to use Makefile.PL for installation was 20020225, so
+ if your previous installation is older than this, it is best to remove
+ it, because the installation path may now be different. There were up
+ to 3 files these older installations: the script `perltidy` and
+ possibly two man pages, `perltidy.1` and `perl2web.1`. If you saved
+ your Makefile, you can probably use `make uninstall`. Otherwise, you
+ can use a `locate` or `find` command to find and remove these files.
+
+- Uninstall older versions when changing installation method
+
+ If you switch from one installation method to another, the paths to the
+ components of perltidy may change, so it is probably best to remove the older
+ version before installing the new version. If your older installation method
+ had an uninstall option (such as with RPM's and debian packages), use it.
+ Otherwise, you can locate and remove the older files by hand. There are two
+ key files: `Tidy.pm` and `perltidy`. In addition, there may be one or two
+ man pages, something like `Perl::Tidy.3pm` and `perltidy.1p`. You can use a
+ `locate` and/or `find` command to find and remove these files. After
+ installation, you can verify that the new version of perltidy is working with
+ the `perltidy -v` command.
+
+# Two Installation Methods - Overview
+
+These are generic instructions. Some system-specific notes and hints
+are given in later sections.
+
+Two separate installation methods are possible.
+
+- Method 1: Standard Installation Method
+
+ The standard method based on MakeMaker should work in a normal perl
+ environment. This is the recommended installation procedure for
+ systems which support it.
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+ The `make` command is probably `nmake` under a Windows system. You
+ may need to become root (or administrator) before doing the `make
+ install` step.
+
+- Method 2: Installation as a single binary script
+
+ If you just want to take perltidy for a quick test drive without installing it,
+ or are having trouble installing modules, you can bundle it all in one
+ independent executable script. This might also be helpful on a system for
+ which the Makefile.PL method does not work, or if you are temporarily a guest
+ on some system, or if you want to try hacking a special version of perltidy
+ without messing up your regular version.
+
+ You just need to uncompress the source distribution, cd down into it, and enter
+ the command:
+
+ perl pm2pl
+
+ which will combine the pieces of perltidy into a single script named
+ `perltidy` in the current directory. This script should be
+ fully functional. Try it out on a handy perl script, for example
+
+ perl perltidy Makefile.PL
+
+ This should create `Makefile.PL.tdy`.
+
+- After Installation
+
+ After installation by either method, verify that the installation worked
+ and that the correct new version is being by entering:
+
+ perltidy -v
+
+ If the version number disagrees with the version number embedded in the
+ distribution file name, search for and remove the old version.
+ For example, under a Unix system, the command `which perltidy` might
+ show where it is. Also, see the above notes on uninstalling older
+ versions.
+
+ On a Unix system running the `bash` shell, if you had a previous
+ installation of perltidy, you may have to use
+
+ hash -r
+
+ to get the shell to find the new one.
+
+ After `perltidy` is installed, you can find where it will look for
+ configuration files and environment variables on your system with
+ the command:
+
+ perltidy -dpro
+
+- How to Uninstall
+
+ Unfortunately, the standard Perl installation method does not seem able
+ to do an uninstall.
+
+ But try this:
+
+ make uninstall
+
+ On some systems, it will give you a list of files to remove by hand. If
+ not, you need to find the script `perltidy` and its module file
+ `Tidy.pm`, which will be in a subdirectory named `Perl` in the site
+ library.
+
+ If you installed perltidy with the alternative method, you should just
+ reverse the steps that you used.
+
+## Unix Installation Notes
+
+- Alternative method - Unix
+
+ If the alternative method is used, test the script produced by the
+ `pm2pl` perl script:
+
+ perl ./perltidy somefile.pl
+
+ where `somefile.pl` is any convenient test file, such as `Makefile.PL`
+ itself. Then,
+
+ 1\. If the script is not executable, use
+
+ chmod +x perltidy
+
+ 2\. Verify that the initial line in perltidy works for your system by
+ entering:
+
+ ./perltidy -h
+
+ which should produce the usage text and then exit. This should usually
+ work, but if it does not, you will need to change the first line in
+ `perltidy` to reflect the location of perl on your system. On a Unix
+ system, you might find the path to perl with the command 'which perl'.
+
+ 3\. A sample `Makefile` for this installation method is `Makefile.npm`.
+ Edit it to have the correct paths.
+
+ You will need to become root unless you change the paths to point to
+ somewhere in your home directory. Then issue the command
+
+ make -f Makefile.npm install
+
+ This installs perltidy and the man page perltidy.1.
+
+ 5\. Test the installation using
+
+ perltidy -h
+
+ You should see the usage screen. Then, if you installed the man pages,
+ try
+
+ man perltidy
+
+ which should bring up the manual page.
+
+ If you ever want to remove perltidy, you can remove perltidy and its man
+ pages by hand or use
+
+ make uninstall
+
+## Windows Installation Notes
+
+On a Windows 9x/Me system you should CLOSE ANY OPEN APPLICATIONS to
+avoid losing unsaved data in case of trouble.
+
+- Standard Method - Windows
+
+ After you unzip the distribution file, the procedure is probably this:
+
+ perl Makefile.PL
+ nmake
+ nmake test
+ nmake install
+
+ You may need to download a copy of `unzip` to unzip the `.zip` distribution
+ file; you can get this at
+ http://www.info-zip.org/pub/infozip/UnZip.html
+
+ If you have ActiveState
+ Perl, the installation method is outlined at
+ http://aspn.activestate.com//ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq9.html#How\_can\_I\_use\_modules\_from\_CPAN\_
+
+ You may need to download a copy of Microsoft's `nmake` program from
+ ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
+
+ If you are not familiar with installing modules, or have trouble doing
+ so, and want to start testing perltidy quickly, you may want to use the
+ alternative method instead (next section).
+
+- Alternative Method - Windows
+
+ From the main installation directory, just enter
+
+ perl pm2pl
+
+ Placing the resulting file `perltidy` and the example batch file
+ `perltidy.bat`, located in the `examples` directory, in your path should
+ work. (You can determine your path by issuing the msdos command
+ `PATH`). However, the batch file probably will not support file
+ redirection. So, for example, to pipe the long help message through
+ 'more', you might have to invoke perltidy with perl directly, like this:
+
+ perl \somepath\perltidy -h | more
+
+ The batch file will not work properly with wildcard filenames, but you may
+ use wildcard filenames if you place them in quotes. For example
+
+ perltidy '*.pl'
+
+## VMS Installation Notes
+
+- Links to VMS Utilities and Documentation
+
+ To install perltidy you will need the following utilities Perl, of
+ course, source with VMS goodies available from
+ http://www.sidhe.org/vmsperl or binary available from the Compaq OpenVMS
+ freeware CD. To unpack the source either gunzip and vmstar available
+ from the Compaq OpenVMS freeware CD or zip available from
+ http://www.info-zip.org/
+
+ To build perltidy you can use either **MMS**, Compaq's VMS equivalent of
+ make, or **MMK**, an **MMS** clone available from
+ http://www.madgoat.com.
+
+ Information on running perl under VMS can be found at:
+ http://w4.lns.cornell.edu/~pvhp/perl/VMS.html
+
+- Unpack the source:
+
+ $ unzip -a perl-tidy-yyyymmdd.zip ! or
+
+ $ unzip /text=auto perl-tidy-yyyymmdd.zip ! or
+
+ $ gunzip perl-tidy-yyyymmdd.tgz
+ $ vmstar perl-tidy-yyyymmdd.tar
+
+- Build and install perltidy under VMS:
+
+ $ set default [.perl-tidy-yyymmdd]
+ $ perl perltidy.pl
+ $ mmk
+ $ mmk test
+ $ mmk install
+
+- Using Perltidy under VMS
+
+ Create a symbol. This should be put in a logon script, eg sylogin.com
+
+ $ perltidy == "perl perl_root:[utils]perltidy."
+
+ Default parameters can be placed in a `perltidyrc` file. Perltidy
+ looks for one in the following places and uses the first found if the
+ logical `PERLTIDY` is a file and the file exists then that is used if the
+ logical `PERLTIDY` is a directory then look for a `.perltidyrc` file in the
+ directory look for a `.perltidyrc` file in the user's home directory
+
+ To see where the search is done and which `.perltidyrc` is used type
+
+ $ perltidy -dpro
+
+ A system `PERLTIDY` logical can be defined pointing to a file with a
+ minimal configuration, and users can defined their own logical to use a
+ personal `.perltidyrc` file.
+
+ $ define /system perltidy perl_root:[utils]perltidy.rc
+
+- The -x Parameter
+
+ If you have one of the magic incantations at the start of perl scripts,
+ so that they can be invoked as a .com file, then you will need to use
+ the **-x** parameter which causes perltidy to skip all lines until it
+ finds a hash bang line eg `#!perl -w`. Since it is such a common
+ option this is probably a good thing to put in a `.perltidyrc` file.
+
+- VMS File Extensions
+
+ VMS file extensions will use an underscore character instead of a dot,
+ when necessary, to create a valid filename. So
+
+ perltidy myfile.pl
+
+ will generate the output file `myfile.pl_tdy` instead of
+ `myfile.pl.tdy`, and so on.
+
+# Troubleshooting / Other Operating Systems
+
+If there seems to be a problem locating a configuration file, you can see
+what is going on in the config file search with:
+
+ perltidy -dpro
+
+If you want to customize where perltidy looks for configuration files,
+look at the routine 'find\_config\_file' in module 'Tidy.pm'. You should
+be able to at least use the '-pro=filename' method under most systems.
+
+Remember to place quotes (either single or double) around input
+parameters which contain spaces, such as file names. For example:
+
+ perltidy "file name with spaces"
+
+Without the quotes, perltidy would look for four files: `file`,
+`name`, `with`, and `spaces`.
+
+If you develop a system-dependent patch that might be of general
+interest, please let us know.
+
+# CONFIGURATION FILE
+
+You do not need a configuration file, but you may eventually want to
+create one to save typing; the tutorial and man page discuss this.
+
+# SYSTEM TEMPORARY FILES
+
+Perltidy needs to create a system temporary file when it invokes
+Pod::Html to format pod text under the -html option. For Unix systems,
+this will normally be a file in /tmp, and for other systems, it will be
+a file in the current working directory named `perltidy.TMP`. This file
+will be removed when the run finishes.
+
+# DOCUMENTATION
+
+Documentation is contained in **.pod** format, either in the `docs` directory
+or appended to the scripts.
+
+These documents can also be found at http://perltidy.sourceforge.net
+
+Reading the brief tutorial should help you use perltidy effectively.
+The tutorial can be read interactively with **perldoc**, for
+example
+
+ cd docs
+ perldoc tutorial.pod
+
+or else an `html` version can be made with **pod2html**:
+
+ pod2html tutorial.pod >tutorial.html
+
+If you use the Makefile.PL installation method on a Unix system, the
+**perltidy** and **Perl::Tidy** man pages should automatically be installed.
+Otherwise, you can extract the man pages with the **pod2xxxx** utilities, as
+follows:
+
+ cd bin
+ pod2text perltidy >perltidy.txt
+ pod2html perltidy >perltidy.html
+
+ cd lib/Perl
+ pod2text Tidy.pm >Tidy.txt
+ pod2html Tidy.pm >Tidy.html
+
+After installation, the installation directory of files may be deleted.
+
+Perltidy is still being developed, so please check sourceforge occasionally
+for updates if you find that it is useful. New releases are announced
+on freshmeat.net.
+
+# CREDITS
+
+Thanks to the many programmers who have documented problems, made suggestions and sent patches.
+
+# FEEDBACK / BUG REPORTS
+
+If you see ways to improve these notes, please let us know.
+
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
+
+To report a new bug or problem, use the link on this page .
.PHONY : all
all:
- pod2html ../local-docs/INSTALL.pod >INSTALL.html
- pod2html ../local-docs/ChangeLog.pod >ChangeLog.html
- pod2html ../local-docs/stylekey.pod >stylekey.html
- pod2html ../local-docs/tutorial.pod >tutorial.html
- pod2html ../bin/perltidy >perltidy.html
- pod2html ../lib/Perl/Tidy.pod >Tidy.html
- markdown index.md >index.html
+ pod2markdown ../local-docs/INSTALL.pod >INSTALL.md
+ pod2markdown ../local-docs/ChangeLog.pod >ChangeLog.md
+ pod2markdown ../local-docs/stylekey.pod >stylekey.md
+ pod2markdown ../local-docs/tutorial.pod >tutorial.md
+ pod2markdown ../bin/perltidy >perltidy.md
+ pod2markdown ../lib/Perl/Tidy.pod >Tidy.md
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#NAME">NAME</a></li>
- <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
- <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
- <li><a href="#ERROR-HANDLING">ERROR HANDLING</a></li>
- <li><a href="#NOTES-ON-FORMATTING-PARAMETERS">NOTES ON FORMATTING PARAMETERS</a></li>
- <li><a href="#EXAMPLES">EXAMPLES</a></li>
- <li><a href="#Using-the-formatter-Callback-Object">Using the formatter Callback Object</a></li>
- <li><a href="#EXPORT">EXPORT</a></li>
- <li><a href="#VERSION">VERSION</a></li>
- <li><a href="#LICENSE">LICENSE</a></li>
- <li><a href="#BUG-REPORTS">BUG REPORTS</a></li>
- <li><a href="#SEE-ALSO">SEE ALSO</a></li>
-</ul>
-
-<h1 id="NAME">NAME</h1>
-
-<p>Perl::Tidy - Parses and beautifies perl source</p>
-
-<h1 id="SYNOPSIS">SYNOPSIS</h1>
-
-<pre><code> use Perl::Tidy;
-
- my $error_flag = Perl::Tidy::perltidy(
- source => $source,
- destination => $destination,
- stderr => $stderr,
- argv => $argv,
- perltidyrc => $perltidyrc,
- logfile => $logfile,
- errorfile => $errorfile,
- formatter => $formatter, # callback object (see below)
- dump_options => $dump_options,
- dump_options_type => $dump_options_type,
- prefilter => $prefilter_coderef,
- postfilter => $postfilter_coderef,
- );</code></pre>
-
-<h1 id="DESCRIPTION">DESCRIPTION</h1>
-
-<p>This module makes the functionality of the perltidy utility available to perl scripts. Any or all of the input parameters may be omitted, in which case the @ARGV array will be used to provide input parameters as described in the perltidy(1) man page.</p>
-
-<p>For example, the perltidy script is basically just this:</p>
-
-<pre><code> use Perl::Tidy;
- Perl::Tidy::perltidy();</code></pre>
-
-<p>The call to <b>perltidy</b> returns a scalar <b>$error_flag</b> which is TRUE if an error caused premature termination, and FALSE if the process ran to normal completion. Additional discuss of errors is contained below in the <a href="#ERROR-HANDLING">"ERROR HANDLING"</a> section.</p>
-
-<p>The module accepts input and output streams by a variety of methods. The following list of parameters may be any of the following: a filename, an ARRAY reference, a SCALAR reference, or an object with either a <b>getline</b> or <b>print</b> method, as appropriate.</p>
-
-<pre><code> source - the source of the script to be formatted
- destination - the destination of the formatted output
- stderr - standard error output
- perltidyrc - the .perltidyrc file
- logfile - the .LOG file stream, if any
- errorfile - the .ERR file stream, if any
- dump_options - ref to a hash to receive parameters (see below),
- dump_options_type - controls contents of dump_options
- dump_getopt_flags - ref to a hash to receive Getopt flags
- dump_options_category - ref to a hash giving category of options
- dump_abbreviations - ref to a hash giving all abbreviations</code></pre>
-
-<p>The following chart illustrates the logic used to decide how to treat a parameter.</p>
-
-<pre><code> ref($param) $param is assumed to be:
- ----------- ---------------------
- undef a filename
- SCALAR ref to string
- ARRAY ref to array
- (other) object with getline (if source) or print method</code></pre>
-
-<p>If the parameter is an object, and the object has a <b>close</b> method, that close method will be called at the end of the stream.</p>
-
-<dl>
-
-<dt id="source">source</dt>
-<dd>
-
-<p>If the <b>source</b> parameter is given, it defines the source of the input stream. If an input stream is defined with the <b>source</b> parameter then no other source filenames may be specified in the @ARGV array or <b>argv</b> parameter.</p>
-
-</dd>
-<dt id="destination">destination</dt>
-<dd>
-
-<p>If the <b>destination</b> parameter is given, it will be used to define the file or memory location to receive output of perltidy.</p>
-
-</dd>
-<dt id="stderr">stderr</dt>
-<dd>
-
-<p>The <b>stderr</b> parameter allows the calling program to redirect the stream that would otherwise go to the standard error output device to any of the stream types listed above. This stream contains important warnings and errors related to the parameters passed to perltidy.</p>
-
-</dd>
-<dt id="perltidyrc">perltidyrc</dt>
-<dd>
-
-<p>If the <b>perltidyrc</b> file is given, it will be used instead of any <i>.perltidyrc</i> configuration file that would otherwise be used.</p>
-
-</dd>
-<dt id="errorfile">errorfile</dt>
-<dd>
-
-<p>The <b>errorfile</b> parameter allows the calling program to capture the stream that would otherwise go to either a .ERR file. This stream contains warnings or errors related to the contents of one source file or stream.</p>
-
-<p>The reason that this is different from the stderr stream is that when perltidy is called to process multiple files there will be up to one .ERR file created for each file and it would be very confusing if they were combined.</p>
-
-<p>However if perltidy is called to process just a single perl script then it may be more convenient to combine the <b>errorfile</b> stream with the <b>stderr</b> stream. This can be done by setting the <b>-se</b> parameter, in which case this parameter is ignored.</p>
-
-</dd>
-<dt id="logfile">logfile</dt>
-<dd>
-
-<p>The <b>logfile</b> parameter allows the calling program to capture the log stream. This stream is only created if requested with a <b>-g</b> parameter. It contains detailed diagnostic information about a script which may be useful for debugging.</p>
-
-</dd>
-<dt id="argv">argv</dt>
-<dd>
-
-<p>If the <b>argv</b> parameter is given, it will be used instead of the <b>@ARGV</b> array. The <b>argv</b> parameter may be a string, a reference to a string, or a reference to an array. If it is a string or reference to a string, it will be parsed into an array of items just as if it were a command line string.</p>
-
-</dd>
-<dt id="dump_options">dump_options</dt>
-<dd>
-
-<p>If the <b>dump_options</b> parameter is given, it must be the reference to a hash. In this case, the parameters contained in any perltidyrc configuration file will be placed in this hash and perltidy will return immediately. This is equivalent to running perltidy with --dump-options, except that the perameters are returned in a hash rather than dumped to standard output. Also, by default only the parameters in the perltidyrc file are returned, but this can be changed (see the next parameter). This parameter provides a convenient method for external programs to read a perltidyrc file. An example program using this feature, <i>perltidyrc_dump.pl</i>, is included in the distribution.</p>
-
-<p>Any combination of the <b>dump_</b> parameters may be used together.</p>
-
-</dd>
-<dt id="dump_options_type">dump_options_type</dt>
-<dd>
-
-<p>This parameter is a string which can be used to control the parameters placed in the hash reference supplied by <b>dump_options</b>. The possible values are 'perltidyrc' (default) and 'full'. The 'full' parameter causes both the default options plus any options found in a perltidyrc file to be returned.</p>
-
-</dd>
-<dt id="dump_getopt_flags">dump_getopt_flags</dt>
-<dd>
-
-<p>If the <b>dump_getopt_flags</b> parameter is given, it must be the reference to a hash. This hash will receive all of the parameters that perltidy understands and flags that are passed to Getopt::Long. This parameter may be used alone or with the <b>dump_options</b> flag. Perltidy will exit immediately after filling this hash. See the demo program <i>perltidyrc_dump.pl</i> for example usage.</p>
-
-</dd>
-<dt id="dump_options_category">dump_options_category</dt>
-<dd>
-
-<p>If the <b>dump_options_category</b> parameter is given, it must be the reference to a hash. This hash will receive a hash with keys equal to all long parameter names and values equal to the title of the corresponding section of the perltidy manual. See the demo program <i>perltidyrc_dump.pl</i> for example usage.</p>
-
-</dd>
-<dt id="dump_abbreviations">dump_abbreviations</dt>
-<dd>
-
-<p>If the <b>dump_abbreviations</b> parameter is given, it must be the reference to a hash. This hash will receive all abbreviations used by Perl::Tidy. See the demo program <i>perltidyrc_dump.pl</i> for example usage.</p>
-
-</dd>
-<dt id="prefilter">prefilter</dt>
-<dd>
-
-<p>A code reference that will be applied to the source before tidying. It is expected to take the full content as a string in its input, and output the transformed content.</p>
-
-</dd>
-<dt id="postfilter">postfilter</dt>
-<dd>
-
-<p>A code reference that will be applied to the tidied result before outputting. It is expected to take the full content as a string in its input, and output the transformed content.</p>
-
-<p>Note: A convenient way to check the function of your custom prefilter and postfilter code is to use the --notidy option, first with just the prefilter and then with both the prefilter and postfilter. See also the file <b>filter_example.pl</b> in the perltidy distribution.</p>
-
-</dd>
-</dl>
-
-<h1 id="ERROR-HANDLING">ERROR HANDLING</h1>
-
-<p>Perltidy will return with an error flag indicating if the process had to be terminated early due to errors in the input parameters. This can happen for example if a parameter is misspelled or given an invalid value. The calling program should check this flag because if it is set the destination stream will be empty or incomplete and should be ignored. Error messages in the <b>stderr</b> stream will indicate the cause of any problem.</p>
-
-<p>If the error flag is not set then perltidy ran to completion. However there may still be warning messages in the <b>stderr</b> stream related to control parameters, and there may be warning messages in the <b>errorfile</b> stream relating to possible syntax errors in the source code being tidied.</p>
-
-<p>In the event of a catastrophic error for which recovery is not possible <b>perltidy</b> terminates by making calls to <b>croak</b> or <b>confess</b> to help the programmer localize the problem. These should normally only occur during program development.</p>
-
-<h1 id="NOTES-ON-FORMATTING-PARAMETERS">NOTES ON FORMATTING PARAMETERS</h1>
-
-<p>Parameters which control formatting may be passed in several ways: in a <i>.perltidyrc</i> configuration file, in the <b>perltidyrc</b> parameter, and in the <b>argv</b> parameter.</p>
-
-<p>The <b>-syn</b> (<b>--check-syntax</b>) flag may be used with all source and destination streams except for standard input and output. However data streams which are not associated with a filename will be copied to a temporary file before being be passed to Perl. This use of temporary files can cause somewhat confusing output from Perl.</p>
-
-<p>If the <b>-pbp</b> style is used it will typically be necessary to also specify a <b>-nst</b> flag. This is necessary to turn off the <b>-st</b> flag contained in the <b>-pbp</b> parameter set which otherwise would direct the output stream to the standard output.</p>
-
-<h1 id="EXAMPLES">EXAMPLES</h1>
-
-<p>The following example uses string references to hold the input and output code and error streams, and illustrates checking for errors.</p>
-
-<pre><code> use Perl::Tidy;
-
- my $source_string = <<'EOT';
- my$error=Perl::Tidy::perltidy(argv=>$argv,source=>\$source_string,
- destination=>\$dest_string,stderr=>\$stderr_string,
- errorfile=>\$errorfile_string,);
- EOT
-
- my $dest_string;
- my $stderr_string;
- my $errorfile_string;
- my $argv = "-npro"; # Ignore any .perltidyrc at this site
- $argv .= " -pbp"; # Format according to perl best practices
- $argv .= " -nst"; # Must turn off -st in case -pbp is specified
- $argv .= " -se"; # -se appends the errorfile to stderr
- ## $argv .= " --spell-check"; # uncomment to trigger an error
-
- print "<<RAW SOURCE>>\n$source_string\n";
-
- my $error = Perl::Tidy::perltidy(
- argv => $argv,
- source => \$source_string,
- destination => \$dest_string,
- stderr => \$stderr_string,
- errorfile => \$errorfile_string, # ignored when -se flag is set
- ##phasers => 'stun', # uncomment to trigger an error
- );
-
- if ($error) {
-
- # serious error in input parameters, no tidied output
- print "<<STDERR>>\n$stderr_string\n";
- die "Exiting because of serious errors\n";
- }
-
- if ($dest_string) { print "<<TIDIED SOURCE>>\n$dest_string\n" }
- if ($stderr_string) { print "<<STDERR>>\n$stderr_string\n" }
- if ($errorfile_string) { print "<<.ERR file>>\n$errorfile_string\n" }</code></pre>
-
-<p>Additional examples are given in examples section of the perltidy distribution.</p>
-
-<h1 id="Using-the-formatter-Callback-Object">Using the <b>formatter</b> Callback Object</h1>
-
-<p>The <b>formatter</b> parameter is an optional callback object which allows the calling program to receive tokenized lines directly from perltidy for further specialized processing. When this parameter is used, the two formatting options which are built into perltidy (beautification or html) are ignored. The following diagram illustrates the logical flow:</p>
-
-<pre><code> |-- (normal route) -> code beautification
- caller->perltidy->|-- (-html flag ) -> create html
- |-- (formatter given)-> callback to write_line</code></pre>
-
-<p>This can be useful for processing perl scripts in some way. The parameter <code>$formatter</code> in the perltidy call,</p>
-
-<pre><code> formatter => $formatter, </code></pre>
-
-<p>is an object created by the caller with a <code>write_line</code> method which will accept and process tokenized lines, one line per call. Here is a simple example of a <code>write_line</code> which merely prints the line number, the line type (as determined by perltidy), and the text of the line:</p>
-
-<pre><code> sub write_line {
-
- # This is called from perltidy line-by-line
- my $self = shift;
- my $line_of_tokens = shift;
- my $line_type = $line_of_tokens->{_line_type};
- my $input_line_number = $line_of_tokens->{_line_number};
- my $input_line = $line_of_tokens->{_line_text};
- print "$input_line_number:$line_type:$input_line";
- }</code></pre>
-
-<p>The complete program, <b>perllinetype</b>, is contained in the examples section of the source distribution. As this example shows, the callback method receives a parameter <b>$line_of_tokens</b>, which is a reference to a hash of other useful information. This example uses these hash entries:</p>
-
-<pre><code> $line_of_tokens->{_line_number} - the line number (1,2,...)
- $line_of_tokens->{_line_text} - the text of the line
- $line_of_tokens->{_line_type} - the type of the line, one of:
-
- SYSTEM - system-specific code before hash-bang line
- CODE - line of perl code (including comments)
- POD_START - line starting pod, such as '=head'
- POD - pod documentation text
- POD_END - last line of pod section, '=cut'
- HERE - text of here-document
- HERE_END - last line of here-doc (target word)
- FORMAT - format section
- FORMAT_END - last line of format section, '.'
- DATA_START - __DATA__ line
- DATA - unidentified text following __DATA__
- END_START - __END__ line
- END - unidentified text following __END__
- ERROR - we are in big trouble, probably not a perl script</code></pre>
-
-<p>Most applications will be only interested in lines of type <b>CODE</b>. For another example, let's write a program which checks for one of the so-called <i>naughty matching variables</i> <code>&`</code>, <code>$&</code>, and <code>$'</code>, which can slow down processing. Here is a <b>write_line</b>, from the example program <b>find_naughty.pl</b>, which does that:</p>
-
-<pre><code> sub write_line {
-
- # This is called back from perltidy line-by-line
- # We're looking for $`, $&, and $'
- my ( $self, $line_of_tokens ) = @_;
-
- # pull out some stuff we might need
- my $line_type = $line_of_tokens->{_line_type};
- my $input_line_number = $line_of_tokens->{_line_number};
- my $input_line = $line_of_tokens->{_line_text};
- my $rtoken_type = $line_of_tokens->{_rtoken_type};
- my $rtokens = $line_of_tokens->{_rtokens};
- chomp $input_line;
-
- # skip comments, pod, etc
- return if ( $line_type ne 'CODE' );
-
- # loop over tokens looking for $`, $&, and $'
- for ( my $j = 0 ; $j < @$rtoken_type ; $j++ ) {
-
- # we only want to examine token types 'i' (identifier)
- next unless $$rtoken_type[$j] eq 'i';
-
- # pull out the actual token text
- my $token = $$rtokens[$j];
-
- # and check it
- if ( $token =~ /^\$[\`\&\']$/ ) {
- print STDERR
- "$input_line_number: $token\n";
- }
- }
- }</code></pre>
-
-<p>This example pulls out these tokenization variables from the $line_of_tokens hash reference:</p>
-
-<pre><code> $rtoken_type = $line_of_tokens->{_rtoken_type};
- $rtokens = $line_of_tokens->{_rtokens};</code></pre>
-
-<p>The variable <code>$rtoken_type</code> is a reference to an array of token type codes, and <code>$rtokens</code> is a reference to a corresponding array of token text. These are obviously only defined for lines of type <b>CODE</b>. Perltidy classifies tokens into types, and has a brief code for each type. You can get a complete list at any time by running perltidy from the command line with</p>
-
-<pre><code> perltidy --dump-token-types</code></pre>
-
-<p>In the present example, we are only looking for tokens of type <b>i</b> (identifiers), so the for loop skips past all other types. When an identifier is found, its actual text is checked to see if it is one being sought. If so, the above write_line prints the token and its line number.</p>
-
-<p>The <b>formatter</b> feature is relatively new in perltidy, and further documentation needs to be written to complete its description. However, several example programs have been written and can be found in the <b>examples</b> section of the source distribution. Probably the best way to get started is to find one of the examples which most closely matches your application and start modifying it.</p>
-
-<p>For help with perltidy's peculiar way of breaking lines into tokens, you might run, from the command line,</p>
-
-<pre><code> perltidy -D filename</code></pre>
-
-<p>where <i>filename</i> is a short script of interest. This will produce <i>filename.DEBUG</i> with interleaved lines of text and their token types. The <b>-D</b> flag has been in perltidy from the beginning for this purpose. If you want to see the code which creates this file, it is <code>write_debug_entry</code> in Tidy.pm.</p>
-
-<h1 id="EXPORT">EXPORT</h1>
-
-<pre><code> &perltidy</code></pre>
-
-<h1 id="VERSION">VERSION</h1>
-
-<p>This man page documents Perl::Tidy version 20180220.01</p>
-
-<h1 id="LICENSE">LICENSE</h1>
-
-<p>This package is free software; you can redistribute it and/or modify it under the terms of the "GNU General Public License".</p>
-
-<p>Please refer to the file "COPYING" for details.</p>
-
-<h1 id="BUG-REPORTS">BUG REPORTS</h1>
-
-<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>
-
-<p>To report a new bug or problem, use the link on this page.</p>
-
-<p>The source code repository is at <a href="https://github.com/perltidy/perltidy">https://github.com/perltidy/perltidy</a>.</p>
-
-<h1 id="SEE-ALSO">SEE ALSO</h1>
-
-<p>The perltidy(1) man page describes all of the features of perltidy. It can be found at http://perltidy.sourceforge.net.</p>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# NAME
+
+Perl::Tidy - Parses and beautifies perl source
+
+# SYNOPSIS
+
+ use Perl::Tidy;
+
+ my $error_flag = Perl::Tidy::perltidy(
+ source => $source,
+ destination => $destination,
+ stderr => $stderr,
+ argv => $argv,
+ perltidyrc => $perltidyrc,
+ logfile => $logfile,
+ errorfile => $errorfile,
+ formatter => $formatter, # callback object (see below)
+ dump_options => $dump_options,
+ dump_options_type => $dump_options_type,
+ prefilter => $prefilter_coderef,
+ postfilter => $postfilter_coderef,
+ );
+
+# DESCRIPTION
+
+This module makes the functionality of the perltidy utility available to perl
+scripts. Any or all of the input parameters may be omitted, in which case the
+@ARGV array will be used to provide input parameters as described
+in the perltidy(1) man page.
+
+For example, the perltidy script is basically just this:
+
+ use Perl::Tidy;
+ Perl::Tidy::perltidy();
+
+The call to **perltidy** returns a scalar **$error\_flag** which is TRUE if an
+error caused premature termination, and FALSE if the process ran to normal
+completion. Additional discuss of errors is contained below in the [ERROR
+HANDLING](https://metacpan.org/pod/ERROR
+HANDLING) section.
+
+The module accepts input and output streams by a variety of methods.
+The following list of parameters may be any of the following: a
+filename, an ARRAY reference, a SCALAR reference, or an object with
+either a **getline** or **print** method, as appropriate.
+
+ source - the source of the script to be formatted
+ destination - the destination of the formatted output
+ stderr - standard error output
+ perltidyrc - the .perltidyrc file
+ logfile - the .LOG file stream, if any
+ errorfile - the .ERR file stream, if any
+ dump_options - ref to a hash to receive parameters (see below),
+ dump_options_type - controls contents of dump_options
+ dump_getopt_flags - ref to a hash to receive Getopt flags
+ dump_options_category - ref to a hash giving category of options
+ dump_abbreviations - ref to a hash giving all abbreviations
+
+The following chart illustrates the logic used to decide how to
+treat a parameter.
+
+ ref($param) $param is assumed to be:
+ ----------- ---------------------
+ undef a filename
+ SCALAR ref to string
+ ARRAY ref to array
+ (other) object with getline (if source) or print method
+
+If the parameter is an object, and the object has a **close** method, that
+close method will be called at the end of the stream.
+
+- source
+
+ If the **source** parameter is given, it defines the source of the input stream.
+ If an input stream is defined with the **source** parameter then no other source
+ filenames may be specified in the @ARGV array or **argv** parameter.
+
+- destination
+
+ If the **destination** parameter is given, it will be used to define the
+ file or memory location to receive output of perltidy.
+
+- stderr
+
+ The **stderr** parameter allows the calling program to redirect the stream that
+ would otherwise go to the standard error output device to any of the stream
+ types listed above. This stream contains important warnings and errors
+ related to the parameters passed to perltidy.
+
+- perltidyrc
+
+ If the **perltidyrc** file is given, it will be used instead of any
+ `.perltidyrc` configuration file that would otherwise be used.
+
+- errorfile
+
+ The **errorfile** parameter allows the calling program to capture
+ the stream that would otherwise go to either a .ERR file. This
+ stream contains warnings or errors related to the contents of one
+ source file or stream.
+
+ The reason that this is different from the stderr stream is that when perltidy
+ is called to process multiple files there will be up to one .ERR file created
+ for each file and it would be very confusing if they were combined.
+
+ However if perltidy is called to process just a single perl script then it may
+ be more convenient to combine the **errorfile** stream with the **stderr**
+ stream. This can be done by setting the **-se** parameter, in which case this
+ parameter is ignored.
+
+- logfile
+
+ The **logfile** parameter allows the calling program to capture the log stream.
+ This stream is only created if requested with a **-g** parameter. It contains
+ detailed diagnostic information about a script which may be useful for
+ debugging.
+
+- argv
+
+ If the **argv** parameter is given, it will be used instead of the
+ **@ARGV** array. The **argv** parameter may be a string, a reference to a
+ string, or a reference to an array. If it is a string or reference to a
+ string, it will be parsed into an array of items just as if it were a
+ command line string.
+
+- dump\_options
+
+ If the **dump\_options** parameter is given, it must be the reference to a hash.
+ In this case, the parameters contained in any perltidyrc configuration file
+ will be placed in this hash and perltidy will return immediately. This is
+ equivalent to running perltidy with --dump-options, except that the perameters
+ are returned in a hash rather than dumped to standard output. Also, by default
+ only the parameters in the perltidyrc file are returned, but this can be
+ changed (see the next parameter). This parameter provides a convenient method
+ for external programs to read a perltidyrc file. An example program using
+ this feature, `perltidyrc_dump.pl`, is included in the distribution.
+
+ Any combination of the **dump\_** parameters may be used together.
+
+- dump\_options\_type
+
+ This parameter is a string which can be used to control the parameters placed
+ in the hash reference supplied by **dump\_options**. The possible values are
+ 'perltidyrc' (default) and 'full'. The 'full' parameter causes both the
+ default options plus any options found in a perltidyrc file to be returned.
+
+- dump\_getopt\_flags
+
+ If the **dump\_getopt\_flags** parameter is given, it must be the reference to a
+ hash. This hash will receive all of the parameters that perltidy understands
+ and flags that are passed to Getopt::Long. This parameter may be
+ used alone or with the **dump\_options** flag. Perltidy will
+ exit immediately after filling this hash. See the demo program
+ `perltidyrc_dump.pl` for example usage.
+
+- dump\_options\_category
+
+ If the **dump\_options\_category** parameter is given, it must be the reference to a
+ hash. This hash will receive a hash with keys equal to all long parameter names
+ and values equal to the title of the corresponding section of the perltidy manual.
+ See the demo program `perltidyrc_dump.pl` for example usage.
+
+- dump\_abbreviations
+
+ If the **dump\_abbreviations** parameter is given, it must be the reference to a
+ hash. This hash will receive all abbreviations used by Perl::Tidy. See the
+ demo program `perltidyrc_dump.pl` for example usage.
+
+- prefilter
+
+ A code reference that will be applied to the source before tidying. It is
+ expected to take the full content as a string in its input, and output the
+ transformed content.
+
+- postfilter
+
+ A code reference that will be applied to the tidied result before outputting.
+ It is expected to take the full content as a string in its input, and output
+ the transformed content.
+
+ Note: A convenient way to check the function of your custom prefilter and
+ postfilter code is to use the --notidy option, first with just the prefilter
+ and then with both the prefilter and postfilter. See also the file
+ **filter\_example.pl** in the perltidy distribution.
+
+# ERROR HANDLING
+
+Perltidy will return with an error flag indicating if the process had to be
+terminated early due to errors in the input parameters. This can happen for
+example if a parameter is misspelled or given an invalid value. The calling
+program should check this flag because if it is set the destination stream will
+be empty or incomplete and should be ignored. Error messages in the **stderr**
+stream will indicate the cause of any problem.
+
+If the error flag is not set then perltidy ran to completion. However there
+may still be warning messages in the **stderr** stream related to control
+parameters, and there may be warning messages in the **errorfile** stream
+relating to possible syntax errors in the source code being tidied.
+
+In the event of a catastrophic error for which recovery is not possible
+**perltidy** terminates by making calls to **croak** or **confess** to help the
+programmer localize the problem. These should normally only occur during
+program development.
+
+# NOTES ON FORMATTING PARAMETERS
+
+Parameters which control formatting may be passed in several ways: in a
+`.perltidyrc` configuration file, in the **perltidyrc** parameter, and in the
+**argv** parameter.
+
+The **-syn** (**--check-syntax**) flag may be used with all source and
+destination streams except for standard input and output. However
+data streams which are not associated with a filename will
+be copied to a temporary file before being be passed to Perl. This
+use of temporary files can cause somewhat confusing output from Perl.
+
+If the **-pbp** style is used it will typically be necessary to also
+specify a **-nst** flag. This is necessary to turn off the **-st** flag
+contained in the **-pbp** parameter set which otherwise would direct
+the output stream to the standard output.
+
+# EXAMPLES
+
+The following example uses string references to hold the input and output
+code and error streams, and illustrates checking for errors.
+
+ use Perl::Tidy;
+
+ my $source_string = <<'EOT';
+ my$error=Perl::Tidy::perltidy(argv=>$argv,source=>\$source_string,
+ destination=>\$dest_string,stderr=>\$stderr_string,
+ errorfile=>\$errorfile_string,);
+ EOT
+
+ my $dest_string;
+ my $stderr_string;
+ my $errorfile_string;
+ my $argv = "-npro"; # Ignore any .perltidyrc at this site
+ $argv .= " -pbp"; # Format according to perl best practices
+ $argv .= " -nst"; # Must turn off -st in case -pbp is specified
+ $argv .= " -se"; # -se appends the errorfile to stderr
+ ## $argv .= " --spell-check"; # uncomment to trigger an error
+
+ print "<<RAW SOURCE>>\n$source_string\n";
+
+ my $error = Perl::Tidy::perltidy(
+ argv => $argv,
+ source => \$source_string,
+ destination => \$dest_string,
+ stderr => \$stderr_string,
+ errorfile => \$errorfile_string, # ignored when -se flag is set
+ ##phasers => 'stun', # uncomment to trigger an error
+ );
+
+ if ($error) {
+
+ # serious error in input parameters, no tidied output
+ print "<<STDERR>>\n$stderr_string\n";
+ die "Exiting because of serious errors\n";
+ }
+
+ if ($dest_string) { print "<<TIDIED SOURCE>>\n$dest_string\n" }
+ if ($stderr_string) { print "<<STDERR>>\n$stderr_string\n" }
+ if ($errorfile_string) { print "<<.ERR file>>\n$errorfile_string\n" }
+
+Additional examples are given in examples section of the perltidy distribution.
+
+# Using the **formatter** Callback Object
+
+The **formatter** parameter is an optional callback object which allows
+the calling program to receive tokenized lines directly from perltidy for
+further specialized processing. When this parameter is used, the two
+formatting options which are built into perltidy (beautification or
+html) are ignored. The following diagram illustrates the logical flow:
+
+ |-- (normal route) -> code beautification
+ caller->perltidy->|-- (-html flag ) -> create html
+ |-- (formatter given)-> callback to write_line
+
+This can be useful for processing perl scripts in some way. The
+parameter `$formatter` in the perltidy call,
+
+ formatter => $formatter,
+
+is an object created by the caller with a `write_line` method which
+will accept and process tokenized lines, one line per call. Here is
+a simple example of a `write_line` which merely prints the line number,
+the line type (as determined by perltidy), and the text of the line:
+
+ sub write_line {
+
+ # This is called from perltidy line-by-line
+ my $self = shift;
+ my $line_of_tokens = shift;
+ my $line_type = $line_of_tokens->{_line_type};
+ my $input_line_number = $line_of_tokens->{_line_number};
+ my $input_line = $line_of_tokens->{_line_text};
+ print "$input_line_number:$line_type:$input_line";
+ }
+
+The complete program, **perllinetype**, is contained in the examples section of
+the source distribution. As this example shows, the callback method
+receives a parameter **$line\_of\_tokens**, which is a reference to a hash
+of other useful information. This example uses these hash entries:
+
+ $line_of_tokens->{_line_number} - the line number (1,2,...)
+ $line_of_tokens->{_line_text} - the text of the line
+ $line_of_tokens->{_line_type} - the type of the line, one of:
+
+ SYSTEM - system-specific code before hash-bang line
+ CODE - line of perl code (including comments)
+ POD_START - line starting pod, such as '=head'
+ POD - pod documentation text
+ POD_END - last line of pod section, '=cut'
+ HERE - text of here-document
+ HERE_END - last line of here-doc (target word)
+ FORMAT - format section
+ FORMAT_END - last line of format section, '.'
+ DATA_START - __DATA__ line
+ DATA - unidentified text following __DATA__
+ END_START - __END__ line
+ END - unidentified text following __END__
+ ERROR - we are in big trouble, probably not a perl script
+
+Most applications will be only interested in lines of type **CODE**. For
+another example, let's write a program which checks for one of the
+so-called _naughty matching variables_ `` &` ``, `$&`, and `$'`, which
+can slow down processing. Here is a **write\_line**, from the example
+program **find\_naughty.pl**, which does that:
+
+ sub write_line {
+
+ # This is called back from perltidy line-by-line
+ # We're looking for $`, $&, and $'
+ my ( $self, $line_of_tokens ) = @_;
+
+ # pull out some stuff we might need
+ my $line_type = $line_of_tokens->{_line_type};
+ my $input_line_number = $line_of_tokens->{_line_number};
+ my $input_line = $line_of_tokens->{_line_text};
+ my $rtoken_type = $line_of_tokens->{_rtoken_type};
+ my $rtokens = $line_of_tokens->{_rtokens};
+ chomp $input_line;
+
+ # skip comments, pod, etc
+ return if ( $line_type ne 'CODE' );
+
+ # loop over tokens looking for $`, $&, and $'
+ for ( my $j = 0 ; $j < @$rtoken_type ; $j++ ) {
+
+ # we only want to examine token types 'i' (identifier)
+ next unless $$rtoken_type[$j] eq 'i';
+
+ # pull out the actual token text
+ my $token = $$rtokens[$j];
+
+ # and check it
+ if ( $token =~ /^\$[\`\&\']$/ ) {
+ print STDERR
+ "$input_line_number: $token\n";
+ }
+ }
+ }
+
+This example pulls out these tokenization variables from the $line\_of\_tokens
+hash reference:
+
+ $rtoken_type = $line_of_tokens->{_rtoken_type};
+ $rtokens = $line_of_tokens->{_rtokens};
+
+The variable `$rtoken_type` is a reference to an array of token type codes,
+and `$rtokens` is a reference to a corresponding array of token text.
+These are obviously only defined for lines of type **CODE**.
+Perltidy classifies tokens into types, and has a brief code for each type.
+You can get a complete list at any time by running perltidy from the
+command line with
+
+ perltidy --dump-token-types
+
+In the present example, we are only looking for tokens of type **i**
+(identifiers), so the for loop skips past all other types. When an
+identifier is found, its actual text is checked to see if it is one
+being sought. If so, the above write\_line prints the token and its
+line number.
+
+The **formatter** feature is relatively new in perltidy, and further
+documentation needs to be written to complete its description. However,
+several example programs have been written and can be found in the
+**examples** section of the source distribution. Probably the best way
+to get started is to find one of the examples which most closely matches
+your application and start modifying it.
+
+For help with perltidy's peculiar way of breaking lines into tokens, you
+might run, from the command line,
+
+ perltidy -D filename
+
+where `filename` is a short script of interest. This will produce
+`filename.DEBUG` with interleaved lines of text and their token types.
+The **-D** flag has been in perltidy from the beginning for this purpose.
+If you want to see the code which creates this file, it is
+`write_debug_entry` in Tidy.pm.
+
+# EXPORT
+
+ &perltidy
+
+# VERSION
+
+This man page documents Perl::Tidy version 20181116
+
+# LICENSE
+
+This package is free software; you can redistribute it and/or modify it
+under the terms of the "GNU General Public License".
+
+Please refer to the file "COPYING" for details.
+
+# BUG REPORTS
+
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
+
+To report a new bug or problem, use the link on this page.
+
+The source code repository is at [https://github.com/perltidy/perltidy](https://github.com/perltidy/perltidy).
+
+# SEE ALSO
+
+The perltidy(1) man page describes all of the features of perltidy. It
+can be found at http://perltidy.sourceforge.net.
+++ /dev/null
-.columns 1
-.side_comment 0
-.bgcolor "#A0E0E0"
-#.contents_file node000
-.pagename node000
-#.icon_path ./icons/
-#.contents_navname Contents
-.up_navname Up
-.border_pix 2
-.image_path
-.big_path
-.max_images_per_page 6
-#.background_file ./icons/tanmarbl.gif
-#./icons/paint.jpg
-#./icons/bluedifftog.jpg
-#.cd
-.title The Perltidy Home Page
-
-<hr>
-
-.h2 Welcome to Perltidy
-
-Perltidy is a Perl script which indents and reformats Perl scripts to make them
-easier to read. If you write Perl scripts, or spend much time
-reading them, you will probably find it useful.
-
-.include examples.alc
-
-The formatting can be controlled with command line parameters. The default
-parameter settings approximately follow the suggestions in the
-<a href="https://perldoc.perl.org/perlstyle.html">
-Perl Style Guide</a>.
-
-Perltidy can also output html of both pod and source code. For example, the
-link below is an html version of the module <b>Conf.pm</b>
-from <a name="SpamAssasin" href="http://spamassassin.apache.org/index.html"> SpamAssassin</a>.
-
-<blockquote><ul>
- <li><a name="Conf.pm" href="Conf.pm.html">An html example</a>
-</ul></blockquote>
-
-Besides reformatting scripts, Perltidy can be a great help in tracking
-down errors with missing or extra braces, parentheses, and square brackets
-because it is very good at localizing errors.
-
-<hr>
-
-.h2 Documentation
-
-<ul>
-
-<li><a href="tutorial.html">A Brief Perltidy Tutorial</a>.
-
-<li><a href="stylekey.html">Perltidy Style Key</a> will
-guide you in methodically selecting a set of style parameters.
-
-<li> The
-<a href="perltidy.html">Perltidy man
-page</a> explains how
-to precisely control the formatting details.
-
-<li> <a href="ChangeLog.html">Change Log</a>.
-
-<li> <a href="BUGS.html">Open BUGS</a>.
-
-<li> The
-<a href="Tidy.html">Perl::Tidy man
-page</a> discusses how to use the Perl::Tidy module.
-
-<li>The license is the <a href="COPYING">GNU General Public License</a>
-
-</ul>
-
-<hr>
-
-.h2 Download
-
-Perltidy should run on any system with perl 5.008 or later.
-<ul>
-
-<li>Please check the <a href="README.html">README File</a>
-
-<li>Please check the <a href="INSTALL.html">Installation Notes</a>
-
-<li>Download <a href="http://prdownloads.sourceforge.net/perltidy/Perl-Tidy-20180220.tar.gz">
-The latest release (.tgz, Unix-style line endings)</a>
-
-<li>Download <a href="http://prdownloads.sourceforge.net/perltidy/Perl-Tidy-20180220.zip">
-The latest release (.zip, Windows-style line endings)</a>
-<li>Debian users can use: apt-get install perltidy
-<li>Download <a href= "http://rpmfind.net/" > rpm's from Rpmfind.Net</a>
-<li> If these links are broken,
-go
-to the download area at
-<a href="http://sourceforge.net/project/?group_id=17029">
-the SourceForge Project Page </a>
-<li> Or look for it at
-<a href="http://search.cpan.org/search?mode=all&query=perltidy">CPAN</a>
-
-</ul>
-
-<hr>
-
-.h2 Links
-
-<ul>
-<li> <a href="http://sourceforge.net/projects/tidyview">Tidyview</a> is a graphical program for tweaking your .perltidyrc configuration parameters.
-<li> <a href="https://github.com/vifo/SublimePerlTidy">https://github.com/vifo/SublimePerlTidy</a> perltidy plugin for Sublime Text 2/3
-</ul>
-
-<hr>
-.h2 Contact
-<ul>
-<li>Author: Steve Hancock
-<li>email: perltidy at users.sourceforge.net
-<li>Thanks to <a href="http://sourceforge.net">SourceForge</a> for hosting this project.
-</ul>
+++ /dev/null
-<h1>Welcome to Perltidy</h1>
-
-<p>Perltidy is a Perl script which indents and reformats Perl scripts to make them
-easier to read. If you write Perl scripts, or spend much time
-reading them, you will probably find it useful.</p>
-
-<p>Perltidy is free software released under the GNU General Public
-License -- please see the included file <a href="./COPYING.txt">COPYING</a> for details.</p>
-
-<p>The formatting can be controlled with command line parameters. The default
-parameter settings approximately follow the suggestions in the
-<a href="https://perldoc.perl.org/perlstyle.html">Perl Style Guide</a>.</p>
-
-<p>Besides reformatting scripts, Perltidy can help in tracking
-down errors with missing or extra braces, parentheses, and square brackets
-because it is very good at localizing errors.</p>
-
-<h2>Documentation</h2>
-
-<ul>
-<li><p><a href="./tutorial.html">A Brief Perltidy Tutorial</a></p></li>
-<li><p><a href="./stylekey.html">Perltidy Style Key</a> will help
-in methodically selecting a set of style parameters.</p></li>
-<li><p><a href="./perltidy.html">The Perltidy man page</a> explains how
-to precisely control the formatting details.</p></li>
-<li><p><a href="./Tidy.html">The Perl::Tidy man page</a> discusses how to use the Perl::Tidy module</p></li>
-<li><p><a href="./ChangeLog.html">Change Log</a></p></li>
-</ul>
-
-<h2>Prerequisites</h2>
-
-<p>Perltidy should run on any system with perl 5.008 or later.
-The total disk space needed after removing the installation directory will be
-about 2 Mb.</p>
-
-<h2>Download</h2>
-
-<ul>
-<li><p>The most recent release is always at <a href="https://metacpan.org/release/Perl-Tidy">CPAN</a></p></li>
-<li><p>The most recent release is also at <a href="https://sourceforge.net/projects/perltidy/">sourceforge</a></p></li>
-<li><p>For related modules search CPAN for <a href="https://metacpan.org/search?q=perltidy">perltidy</a></p></li>
-</ul>
-
-<h2>Installation</h2>
-
-<p>Perl::Tidy can be installed directly from CPAN one of the available methods.</p>
-
-<p>One way is to download a distribution file, unpack it and then
-test and install using the Makefile.PL:</p>
-
-<pre><code>perl Makefile.PL
-make
-make test
-make install
-</code></pre>
-
-<p>The <a href="./INSTALL.html">INSTALL file</a> has additional installation notes, and tells how
-to use perltidy without doing an installation.</p>
-
-<h2>Links</h2>
-
-<ul>
-<li><a href="https://github.com/perltidy/perltidy">Perl::Tidy source code repository at GitHub</a></li>
-<li><a href="http://sourceforge.net/projects/tidyview">Tidyview</a> is a graphical program for tweaking your .perltidyrc configuration parameters.</li>
-<li><a href="https://github.com/vifo/SublimePerlTidy">A perltidy plugin for Sublime Text 2/3</a></li>
-</ul>
-
-<h2>FEEDBACK / BUG REPORTS</h2>
-
-<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>
-
-<p>To report a new bug or problem, use the link on this page .</p>
The formatting can be controlled with command line parameters. The default
parameter settings approximately follow the suggestions in the
-[Perl Style Guide](https://perldoc.perl.org/perlstyle.html).
+[Perl Style Guide](https://perldoc.perl.org/perlstyle.md).
Besides reformatting scripts, Perltidy can help in tracking
down errors with missing or extra braces, parentheses, and square brackets
## Documentation
-- [A Brief Perltidy Tutorial](./tutorial.html)
+- [A Brief Perltidy Tutorial](./tutorial.md)
-- [Perltidy Style Key](./stylekey.html) will help
+- [Perltidy Style Key](./stylekey.md) will help
in methodically selecting a set of style parameters.
-- [The Perltidy man page](./perltidy.html) explains how
+- [The Perltidy man page](./perltidy.md) explains how
to precisely control the formatting details.
-- [The Perl::Tidy man page](./Tidy.html) discusses how to use the Perl::Tidy module
+- [The Perl::Tidy man page](./Tidy.md) discusses how to use the Perl::Tidy module
-- [Change Log](./ChangeLog.html)
+- [Change Log](./ChangeLog.md)
## Prerequisites
make test
make install
-The [INSTALL file](./INSTALL.html) has additional installation notes, and tells how
+The [INSTALL file](./INSTALL.md) has additional installation notes, and tells how
to use perltidy without doing an installation.
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#NAME">NAME</a></li>
- <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
- <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
- <li><a href="#EXAMPLES">EXAMPLES</a></li>
- <li><a href="#OPTIONS---OVERVIEW">OPTIONS - OVERVIEW</a>
- <ul>
- <li><a href="#I-O-control">I/O control</a></li>
- </ul>
- </li>
- <li><a href="#FORMATTING-OPTIONS">FORMATTING OPTIONS</a>
- <ul>
- <li><a href="#Basic-Options">Basic Options</a></li>
- <li><a href="#Code-Indentation-Control">Code Indentation Control</a></li>
- <li><a href="#Whitespace-Control">Whitespace Control</a></li>
- <li><a href="#Comment-Controls">Comment Controls</a></li>
- <li><a href="#Skipping-Selected-Sections-of-Code">Skipping Selected Sections of Code</a></li>
- <li><a href="#Line-Break-Control">Line Break Control</a></li>
- <li><a href="#Controlling-List-Formatting">Controlling List Formatting</a></li>
- <li><a href="#Retaining-or-Ignoring-Existing-Line-Breaks">Retaining or Ignoring Existing Line Breaks</a></li>
- <li><a href="#Blank-Line-Control">Blank Line Control</a></li>
- <li><a href="#Styles">Styles</a></li>
- <li><a href="#Controlling-Vertical-Alignment">Controlling Vertical Alignment</a></li>
- <li><a href="#Other-Controls">Other Controls</a></li>
- </ul>
- </li>
- <li><a href="#HTML-OPTIONS">HTML OPTIONS</a></li>
- <li><a href="#SOME-COMMON-INPUT-CONVENTIONS">SOME COMMON INPUT CONVENTIONS</a>
- <ul>
- <li><a href="#Specifying-Block-Types">Specifying Block Types</a></li>
- <li><a href="#Specifying-File-Extensions">Specifying File Extensions</a></li>
- </ul>
- </li>
- <li><a href="#SWITCHES-WHICH-MAY-BE-NEGATED">SWITCHES WHICH MAY BE NEGATED</a></li>
- <li><a href="#LIMITATIONS">LIMITATIONS</a></li>
- <li><a href="#FILES">FILES</a></li>
- <li><a href="#SEE-ALSO">SEE ALSO</a></li>
- <li><a href="#VERSION">VERSION</a></li>
- <li><a href="#BUG-REPORTS">BUG REPORTS</a></li>
- <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
- <li><a href="#LICENSE">LICENSE</a></li>
- <li><a href="#DISCLAIMER">DISCLAIMER</a></li>
-</ul>
-
-<h1 id="NAME">NAME</h1>
-
-<p>perltidy - a perl script indenter and reformatter</p>
-
-<h1 id="SYNOPSIS">SYNOPSIS</h1>
-
-<pre><code> perltidy [ options ] file1 file2 file3 ...
- (output goes to file1.tdy, file2.tdy, file3.tdy, ...)
- perltidy [ options ] file1 -o outfile
- perltidy [ options ] file1 -st >outfile
- perltidy [ options ] <infile >outfile</code></pre>
-
-<h1 id="DESCRIPTION">DESCRIPTION</h1>
-
-<p>Perltidy reads a perl script and writes an indented, reformatted script.</p>
-
-<p>Many users will find enough information in <a href="#EXAMPLES">"EXAMPLES"</a> to get started. New users may benefit from the short tutorial which can be found at http://perltidy.sourceforge.net/tutorial.html</p>
-
-<p>A convenient aid to systematically defining a set of style parameters can be found at http://perltidy.sourceforge.net/stylekey.html</p>
-
-<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">"FORMATTING OPTIONS"</a>.</p>
-
-<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">"HTML OPTIONS"</a>.</p>
-
-<h1 id="EXAMPLES">EXAMPLES</h1>
-
-<pre><code> perltidy somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy *.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -b file1.pl file2.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -b -bext='/' file1.pl file2.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -gnu somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -i=3 somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -i=3 -et=8 somefile.pl</code></pre>
-
-<p>Same as the previous example, except that leading whitespace will be entabbed with one tab character per 8 spaces.</p>
-
-<pre><code> perltidy -ce -l=72 somefile.pl</code></pre>
-
-<p>Execute perltidy on file <i>somefile.pl</i> with all defaults except use "cuddled elses" (<b>-ce</b>) and a maximum line length of 72 columns (<b>-l=72</b>) instead of the default 80 columns.</p>
-
-<pre><code> perltidy -g somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -html somefile.pl</code></pre>
-
-<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 <HEAD> section which may be edited to change the appearance.</p>
-
-<pre><code> perltidy -html -css=mystyle.css somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -html -pre somefile.pl</code></pre>
-
-<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>
-
-<pre><code> perltidy -html -ss >mystyle.css</code></pre>
-
-<p>Write a style sheet to <i>mystyle.css</i> and exit.</p>
-
-<pre><code> perltidy -html -frm mymodule.pm</code></pre>
-
-<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>
-
-<h1 id="OPTIONS---OVERVIEW">OPTIONS - OVERVIEW</h1>
-
-<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>
-
-<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>
-
-<p>Most parameters which serve as on/off flags can be negated with a leading "n" (for the short name) or a leading "no" or "no-" (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>
-
-<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>
-
-<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>
-
-<h2 id="I-O-control">I/O control</h2>
-
-<p>The following parameters concern the files which are read and written.</p>
-
-<dl>
-
-<dt id="h---help"><b>-h</b>, <b>--help</b></dt>
-<dd>
-
-<p>Show summary of usage and exit.</p>
-
-</dd>
-<dt id="o-filename---outfile-filename"><b>-o</b>=filename, <b>--outfile</b>=filename</dt>
-<dd>
-
-<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, the output will go to <i>filename.tdy</i>.</p>
-
-</dd>
-<dt id="st---standard-output"><b>-st</b>, <b>--standard-output</b></dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy somefile.pl -st >somefile.new.pl</code></pre>
-
-<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>
-
-</dd>
-<dt id="se---standard-error-output"><b>-se</b>, <b>--standard-error-output</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="oext-ext---output-file-extension-ext"><b>-oext</b>=ext, <b>--output-file-extension</b>=ext</dt>
-<dd>
-
-<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">"Specifying File Extensions"</a>.</p>
-
-</dd>
-<dt id="opath-path---output-path-path"><b>-opath</b>=path, <b>--output-path</b>=path</dt>
-<dd>
-
-<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>
-
-<p>The path should end in a valid path separator character, but perltidy will try to add one if it is missing.</p>
-
-<p>For example</p>
-
-<pre><code> perltidy somefile.pl -opath=/tmp/</code></pre>
-
-<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>
-
-<p>If the path contains spaces, it should be placed in quotes.</p>
-
-<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>
-
-</dd>
-<dt id="b---backup-and-modify-in-place"><b>-b</b>, <b>--backup-and-modify-in-place</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="bext-ext---backup-file-extension-ext"><b>-bext</b>=ext, <b>--backup-file-extension</b>=ext</dt>
-<dd>
-
-<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>
-
-<p>To change the default extension to something other than <i>.bak</i> see <a href="#Specifying-File-Extensions">"Specifying File Extensions"</a>.</p>
-
-<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>
-
-<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>
-
-<p>Here are some examples:</p>
-
-<pre><code> Parameter Extension Backup File Treatment
- <-bext=bak> F<.bak> Keep (same as the default behavior)
- <-bext='/'> F<.bak> Delete if no errors
- <-bext='/backup'> F<.backup> Delete if no errors
- <-bext='original/'> F<.original> Delete if no errors</code></pre>
-
-</dd>
-<dt id="w---warning-output"><b>-w</b>, <b>--warning-output</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="q---quiet"><b>-q</b>, <b>--quiet</b></dt>
-<dd>
-
-<p>Deactivate error messages and syntax checking (for running under an editor).</p>
-
-<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>
-
-<pre><code> :n1,n2!perltidy -q</code></pre>
-
-<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 "undo" key.</p>
-
-</dd>
-<dt id="log---logfile"><b>-log</b>, <b>--logfile</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="g-n---logfile-gap-n"><b>-g=n</b>, <b>--logfile-gap=n</b></dt>
-<dd>
-
-<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>
-
-<p>Setting <b>-g</b> also causes the logfile to be saved, so it is not necessary to also include <b>-log</b>.</p>
-
-<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>
-
-<p>Setting a negative value of <code>n</code> is the same as not setting <b>-g</b> at all.</p>
-
-</dd>
-<dt id="npro---noprofile"><b>-npro</b> <b>--noprofile</b></dt>
-<dd>
-
-<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>
-
-<p>If you set the <b>-npro</b> flag, perltidy will not look for this file.</p>
-
-</dd>
-<dt id="pro-filename-or---profile-filename"><b>-pro=filename</b> or <b>--profile=filename</b></dt>
-<dd>
-
-<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 '=' sign. For example, the line</p>
-
-<pre><code> perltidy -pro=testcfg</code></pre>
-
-<p>would cause file <i>testcfg</i> to be used instead of the default <i>.perltidyrc</i>.</p>
-
-<p>A pathname begins with three dots, e.g. ".../.perltidyrc", 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>
-
-</dd>
-<dt id="opt---show-options"><b>-opt</b>, <b>--show-options</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="f---force-read-binary"><b>-f</b>, <b>--force-read-binary</b></dt>
-<dd>
-
-<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>
-
-</dd>
-</dl>
-
-<h1 id="FORMATTING-OPTIONS">FORMATTING OPTIONS</h1>
-
-<h2 id="Basic-Options">Basic Options</h2>
-
-<dl>
-
-<dt id="notidy"><b>--notidy</b></dt>
-<dd>
-
-<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">"Skipping Selected Sections of Code"</a> for a way to avoid tidying specific sections of code.</p>
-
-</dd>
-<dt id="i-n---indent-columns-n"><b>-i=n</b>, <b>--indent-columns=n</b></dt>
-<dd>
-
-<p>Use n columns per indentation level (default n=4).</p>
-
-</dd>
-<dt id="l-n---maximum-line-length-n"><b>-l=n</b>, <b>--maximum-line-length=n</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="vmll---variable-maximum-line-length"><b>-vmll</b>, <b>--variable-maximum-line-length</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-<pre><code> M is the value of --maximum-line-length=M (-l=M), default 80,
- I is the value of --indent-columns=I (-i=I), default 4,
- L is the indentation level of the line of code</code></pre>
-
-<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>
-
-<p>The default is not to do this (<b>-nvmll</b>).</p>
-
-</dd>
-<dt id="wc-n---whitespace-cycle-n"><b>-wc=n</b>, <b>--whitespace-cycle=n</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-<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>
-
-<p>The default is not to use this, which can also be indicated using <b>-wc=0</b>.</p>
-
-</dd>
-<dt id="tabs">tabs</dt>
-<dd>
-
-<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>
-
-<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>
-
-<dl>
-
-<dt id="et-n---entab-leading-whitespace"><b>-et=n</b>, <b>--entab-leading-whitespace</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="t---tabs"><b>-t</b>, <b>--tabs</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="dt-n---default-tabsize-n"><b>-dt=n</b>, <b>--default-tabsize=n</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-</dl>
-
-</dd>
-<dt id="syn---check-syntax"><b>-syn</b>, <b>--check-syntax</b></dt>
-<dd>
-
-<p>This flag is now ignored for safety, but the following documentation has been retained for reference.</p>
-
-<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 "second opinion".</p>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="pscf-s--perl-syntax-check-flags-s"><b>-pscf=s</b>, <b>-perl-syntax-check-flags=s</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="xs---extended-syntax"><b>-xs</b>, <b>--extended-syntax</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-<pre><code> method deposit( Num $amount) {
- $self->balance( $self->balance + $amount );
- }</code></pre>
-
-<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>
-
-</dd>
-<dt id="io---indent-only"><b>-io</b>, <b>--indent-only</b></dt>
-<dd>
-
-<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>
-
-<p>Setting this flag is equivalent to setting <b>--freeze-newlines</b> and <b>--freeze-whitespace</b>.</p>
-
-<p>If you also want to keep your existing blank lines exactly as they are, you can add <b>--freeze-blank-lines</b>.</p>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="enc-s---character-encoding-s"><b>-enc=s</b>, <b>--character-encoding=s</b></dt>
-<dd>
-
-<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>'use utf8'</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>
-
-<p>The default is <b>none</b>.</p>
-
-<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>
-
-<pre><code> perltidy -utf8 file.pl</code></pre>
-
-</dd>
-<dt id="ole-s---output-line-ending-s"><b>-ole=s</b>, <b>--output-line-ending=s</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="ple---preserve-line-endings"><b>-ple</b>, <b>--preserve-line-endings</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="it-n---iterations-n"><b>-it=n</b>, <b>--iterations=n</b></dt>
-<dd>
-
-<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>
-
-<p>This flag has no effect when perltidy is used to generate html.</p>
-
-</dd>
-<dt id="conv---converge"><b>-conv</b>, <b>--converge</b></dt>
-<dd>
-
-<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>
-
-</dd>
-</dl>
-
-<h2 id="Code-Indentation-Control">Code Indentation Control</h2>
-
-<dl>
-
-<dt id="ci-n---continuation-indentation-n"><b>-ci=n</b>, <b>--continuation-indentation=n</b></dt>
-<dd>
-
-<p>Continuation indentation is extra indentation spaces applied when a long line is broken. The default is n=2, illustrated here:</p>
-
-<pre><code> my $level = # -ci=2
- ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;</code></pre>
-
-<p>The same example, with n=0, is a little harder to read:</p>
-
-<pre><code> my $level = # -ci=0
- ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;</code></pre>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="sil-n---starting-indentation-level-n"><b>-sil=n</b> <b>--starting-indentation-level=n</b></dt>
-<dd>
-
-<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>
-
-<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'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>
-
-<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>
-
-</dd>
-<dt id="List-indentation-using--lp---line-up-parentheses">List indentation using <b>-lp</b>, <b>--line-up-parentheses</b></dt>
-<dd>
-
-<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>
-
-<pre><code> # perltidy (default)
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<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>
-
-<pre><code> # perltidy -lp
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="cti-n---closing-token-indentation"><b>-cti=n</b>, <b>--closing-token-indentation</b></dt>
-<dd>
-
-<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>
-
-<pre><code> -cti = 0 no extra indentation (default)
- -cti = 1 extra indentation such that the closing token
- aligns with its opening token.
- -cti = 2 one extra indentation level if the line looks like:
- ); or ]; or };
- -cti = 3 one extra indentation level always</code></pre>
-
-<p>The flags <b>-cti=1</b> and <b>-cti=2</b> work well with the <b>-lp</b> flag (previous section).</p>
-
-<pre><code> # perltidy -lp -cti=1
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );
-
- # perltidy -lp -cti=2
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<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>
-
-<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>'s, <b>-csbi</b> or <b>--closing-square-bracket-indentation</b> controls <b>]</b>'s, <b>-cbi</b> or <b>--closing-brace-indentation</b> controls non-block <b>}</b>'s.</p>
-
-</dd>
-<dt id="icp---indent-closing-paren"><b>-icp</b>, <b>--indent-closing-paren</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="icb---indent-closing-brace"><b>-icb</b>, <b>--indent-closing-brace</b></dt>
-<dd>
-
-<p>The <b>-icb</b> option gives one extra level of indentation to a brace which terminates a code block . For example,</p>
-
-<pre><code> if ($task) {
- yyy();
- } # -icb
- else {
- zzz();
- }</code></pre>
-
-<p>The default is not to do this, indicated by <b>-nicb</b>.</p>
-
-</dd>
-<dt id="olq---outdent-long-quotes"><b>-olq</b>, <b>--outdent-long-quotes</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="oll---outdent-long-lines"><b>-oll</b>, <b>--outdent-long-lines</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Outdenting-Labels:--ola---outdent-labels">Outdenting Labels: <b>-ola</b>, <b>--outdent-labels</b></dt>
-<dd>
-
-<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>
-
-<pre><code> my $i;
- LOOP: while ( $i = <FOTOS> ) {
- chomp($i);
- next unless $i;
- fixit($i);
- }</code></pre>
-
-<p>Use <b>-nola</b> to not outdent labels.</p>
-
-</dd>
-<dt id="Outdenting-Keywords">Outdenting Keywords</dt>
-<dd>
-
-<dl>
-
-<dt id="okw---outdent-keywords"><b>-okw</b>, <b>--outdent-keywords</b></dt>
-<dd>
-
-<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>
-
-<p>For example, using <code>perltidy -okw</code> on the previous example gives:</p>
-
-<pre><code> my $i;
- LOOP: while ( $i = <FOTOS> ) {
- chomp($i);
- next unless $i;
- fixit($i);
- }</code></pre>
-
-<p>The default is not to do this.</p>
-
-</dd>
-<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>
-<dd>
-
-<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>
-
-<p>For example, the commands <code>-okwl="next last redo goto" -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>
-
-</dd>
-</dl>
-
-</dd>
-</dl>
-
-<h2 id="Whitespace-Control">Whitespace Control</h2>
-
-<p>Whitespace refers to the blank space between variables, operators, and other code tokens.</p>
-
-<dl>
-
-<dt id="fws---freeze-whitespace"><b>-fws</b>, <b>--freeze-whitespace</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Tightness-of-curly-braces-parentheses-and-square-brackets">Tightness of curly braces, parentheses, and square brackets.</dt>
-<dd>
-
-<p>Here the term "tightness" 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>
-
-<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>
-
-<pre><code> if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
- if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
- if ((my $len_tab = length($tabstr)) > 0) { # -pt=2</code></pre>
-
-<p>When n is 0, there is always a space to the right of a '(' and to the left of a ')'. 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>
-
-<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>
-
-<pre><code> $width = $col[ $j + $k ] - $col[ $j ]; # -sbt=0
- $width = $col[ $j + $k ] - $col[$j]; # -sbt=1 (default)
- $width = $col[$j + $k] - $col[$j]; # -sbt=2 </code></pre>
-
-<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>
-
-<pre><code> $obj->{ $parsed_sql->{ 'table' }[0] }; # -bt=0
- $obj->{ $parsed_sql->{'table'}[0] }; # -bt=1 (default)
- $obj->{$parsed_sql->{'table'}[0]}; # -bt=2</code></pre>
-
-<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>
-
-<pre><code> %bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.'; # -bbt=0 (default)
- %bf = map { $_ => -M $_ } grep {/\.deb$/} dirents '.'; # -bbt=1
- %bf = map {$_ => -M $_} grep {/\.deb$/} dirents '.'; # -bbt=2</code></pre>
-
-<p>To simplify input in the case that all of the tightness flags have the same value <n>, the parameter <-act=n> or <b>--all-containers-tightness=n</b> is an abbreviation for the combination <-pt=n -sbt=n -bt=n -bbt=n>.</p>
-
-</dd>
-<dt id="tso---tight-secret-operators"><b>-tso</b>, <b>--tight-secret-operators</b></dt>
-<dd>
-
-<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 "tightly" (without spaces). The operators currently modified by this flag are:</p>
-
-<pre><code> 0+ +0 ()x!! ~~<> ,=> =( )= </code></pre>
-
-<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>
-
-</dd>
-<dt id="sts---space-terminal-semicolon"><b>-sts</b>, <b>--space-terminal-semicolon</b></dt>
-<dd>
-
-<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>
-
-<pre><code> $i = 1 ; # -sts
- $i = 1; # -nsts (default)</code></pre>
-
-</dd>
-<dt id="sfs---space-for-semicolon"><b>-sfs</b>, <b>--space-for-semicolon</b></dt>
-<dd>
-
-<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>
-
-<pre><code> for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) { # -sfs (default)
- for ( @a = @$ap, $u = shift @a; @a; $u = $v ) { # -nsfs</code></pre>
-
-</dd>
-<dt id="asc---add-semicolons"><b>-asc</b>, <b>--add-semicolons</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="dsm---delete-semicolons"><b>-dsm</b>, <b>--delete-semicolons</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="aws---add-whitespace"><b>-aws</b>, <b>--add-whitespace</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="dws---delete-old-whitespace"><b>-dws</b>, <b>--delete-old-whitespace</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Detailed-whitespace-controls-around-tokens">Detailed whitespace controls around tokens</dt>
-<dd>
-
-<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>
-
-<p><b>-wls=s</b> or <b>--want-left-space=s</b>,</p>
-
-<p><b>-nwls=s</b> or <b>--nowant-left-space=s</b>,</p>
-
-<p><b>-wrs=s</b> or <b>--want-right-space=s</b>,</p>
-
-<p><b>-nwrs=s</b> or <b>--nowant-right-space=s</b>.</p>
-
-<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>
-
-<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>
-
-<pre><code> -nwls="= + - / *" -nwrs="= + - / *"</code></pre>
-
-<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>
-
-<pre><code> $root = -$b + sqrt( $b * $b - 4. * $a * $c ) / ( 2. * $a );</code></pre>
-
-<p>becomes this:</p>
-
-<pre><code> $root=-$b+sqrt( $b*$b-4.*$a*$c )/( 2.*$a );</code></pre>
-
-<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't. In this case, the token not wanting a space takes priority.</p>
-
-<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>
-
-<p><b>WARNING</b> Be sure to put these tokens in quotes to avoid having them misinterpreted by your command shell.</p>
-
-</dd>
-<dt id="Space-between-specific-keywords-and-opening-paren">Space between specific keywords and opening paren</dt>
-<dd>
-
-<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>
-
-<pre><code> my local our and or eq ne if else elsif until unless
- while for foreach return switch case given when</code></pre>
-
-<p>These defaults can be modified with two commands:</p>
-
-<p><b>-sak=s</b> or <b>--space-after-keyword=s</b> adds keywords.</p>
-
-<p><b>-nsak=s</b> or <b>--nospace-after-keyword=s</b> removes keywords.</p>
-
-<p>where <b>s</b> is a list of keywords (in quotes if necessary). For example,</p>
-
-<pre><code> my ( $a, $b, $c ) = @_; # default
- my( $a, $b, $c ) = @_; # -nsak="my local our"</code></pre>
-
-<p>The abbreviation <b>-nsak='*'</b> is equivalent to including all of the keywords in the above list.</p>
-
-<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="*" -sak="my local our"</b>.</p>
-
-<p>To put a space after all keywords, see the next item.</p>
-
-</dd>
-<dt id="Space-between-all-keywords-and-opening-parens">Space between all keywords and opening parens</dt>
-<dd>
-
-<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>
-
-<p><b>-skp</b> or <b>--space-keyword-paren</b></p>
-
-<p>You will probably also want to use the flag <b>-sfp</b> (next item) too.</p>
-
-</dd>
-<dt id="Space-between-all-function-names-and-opening-parens">Space between all function names and opening parens</dt>
-<dd>
-
-<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>
-
-<p><b>-sfp</b> or <b>--space-function-paren</b></p>
-
-<pre><code> myfunc( $a, $b, $c ); # default
- myfunc ( $a, $b, $c ); # -sfp</code></pre>
-
-<p>You will probably also want to use the flag <b>-skp</b> (previous item) too.</p>
-
-</dd>
-<dt id="Trimming-whitespace-around-qw-quotes">Trimming whitespace around <code>qw</code> quotes</dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="sbq-n-or---space-backslash-quote-n"><b>-sbq=n</b> or <b>--space-backslash-quote=n</b></dt>
-<dd>
-
-<p>Lines like</p>
-
-<pre><code> $str1=\"string1";
- $str2=\'string2';</code></pre>
-
-<p>can confuse syntax highlighters unless a space is included between the backslash and the single or double quotation mark.</p>
-
-<p>This can be controlled with the value of <b>n</b> as follows:</p>
-
-<pre><code> -sbq=0 means no space between the backslash and quote
- -sbq=1 means follow the example of the source code
- -sbq=2 means always put a space between the backslash and quote</code></pre>
-
-<p>The default is <b>-sbq=1</b>, meaning that a space will be used 0if there is one in the source code.</p>
-
-</dd>
-<dt id="Trimming-trailing-whitespace-from-lines-of-POD">Trimming trailing whitespace from lines of POD</dt>
-<dd>
-
-<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>
-
-</dd>
-</dl>
-
-<h2 id="Comment-Controls">Comment Controls</h2>
-
-<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>
-
-<dl>
-
-<dt id="ibc---indent-block-comments"><b>-ibc</b>, <b>--indent-block-comments</b></dt>
-<dd>
-
-<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>
-
-<pre><code> # this comment is indented (-ibc, default)
- if ($task) { yyy(); }</code></pre>
-
-<p>The alternative is <b>-nibc</b>:</p>
-
-<pre><code> # this comment is not indented (-nibc)
- if ($task) { yyy(); }</code></pre>
-
-<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>
-
-</dd>
-<dt id="isbc---indent-spaced-block-comments"><b>-isbc</b>, <b>--indent-spaced-block-comments</b></dt>
-<dd>
-
-<p>If there is no leading space on the line, then the comment will not be indented, and otherwise it may be.</p>
-
-<p>If both <b>-ibc</b> and <b>-isbc</b> are set, then <b>-isbc</b> takes priority.</p>
-
-</dd>
-<dt id="olc---outdent-long-comments"><b>-olc</b>, <b>--outdent-long-comments</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="msc-n---minimum-space-to-comment-n"><b>-msc=n</b>, <b>--minimum-space-to-comment=n</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="fpsc-n---fixed-position-side-comment-n"><b>-fpsc=n</b>, <b>--fixed-position-side-comment=n</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="iscl---ignore-side-comment-lengths"><b>-iscl</b>, <b>--ignore-side-comment-lengths</b></dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy -l=80 -iscl
- $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well</code></pre>
-
-<p>whereas without the -iscl flag the line will be broken:</p>
-
-<pre><code> perltidy -l=80
- $vmsfile =~ s/;[\d\-]*$//
- ; # Clip off version number; we can use a newer version as well
- </code></pre>
-
-</dd>
-<dt id="hsc---hanging-side-comments"><b>-hsc</b>, <b>--hanging-side-comments</b></dt>
-<dd>
-
-<p>By default, perltidy tries to identify and align "hanging side comments", which are something like this:</p>
-
-<pre><code> my $IGNORE = 0; # This is a side comment
- # This is a hanging side comment
- # And so is this</code></pre>
-
-<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>
-
-</dd>
-<dt id="Closing-Side-Comments">Closing Side Comments</dt>
-<dd>
-
-<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>
-
-<pre><code> sub message {
- if ( !defined( $_[0] ) ) {
- print("Hello, World\n");
- }
- else {
- print( $_[0], "\n" );
- }
- }</code></pre>
-
-<p>And here is the result of processing with <code>perltidy -csc</code>:</p>
-
-<pre><code> sub message {
- if ( !defined( $_[0] ) ) {
- print("Hello, World\n");
- }
- else {
- print( $_[0], "\n" );
- }
- } ## end sub message</code></pre>
-
-<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>
-
-<p>The command <b>-dcsc</b> (or <b>--delete-closing-side-comments</b>) reverses this process and removes these comments.</p>
-
-<p>Several commands are available to modify the behavior of these two basic commands, <b>-csc</b> and <b>-dcsc</b>:</p>
-
-<dl>
-
-<dt id="csci-n-or---closing-side-comment-interval-n"><b>-csci=n</b>, or <b>--closing-side-comment-interval=n</b></dt>
-<dd>
-
-<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>
-
-<pre><code> # perltidy -csci=2 -csc
- sub message {
- if ( !defined( $_[0] ) ) {
- print("Hello, World\n");
- } ## end if ( !defined( $_[0] ))
- else {
- print( $_[0], "\n" );
- } ## end else [ if ( !defined( $_[0] ))
- } ## end sub message</code></pre>
-
-<p>Now the <code>if</code> and <code>else</code> blocks are commented. However, now this has become very cluttered.</p>
-
-</dd>
-<dt id="cscp-string-or---closing-side-comment-prefix-string"><b>-cscp=string</b>, or <b>--closing-side-comment-prefix=string</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="cscl-string-or---closing-side-comment-list"><b>-cscl=string</b>, or <b>--closing-side-comment-list</b></dt>
-<dd>
-
-<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">"Specifying Block Types"</a>. For example, the following command requests that only <code>sub</code>'s, labels, <code>BEGIN</code>, and <code>END</code> blocks be affected by any <b>-csc</b> or <b>-dcsc</b> operation:</p>
-
-<pre><code> -cscl="sub : BEGIN END"</code></pre>
-
-</dd>
-<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>
-<dd>
-
-<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>
-
-</dd>
-<dt id="cscb-or---closing-side-comments-balanced"><b>-cscb</b>, or <b>--closing-side-comments-balanced</b></dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy -csc -ncscb
- } ## end foreach my $foo (sort { $b cmp $a ...</code></pre>
-
-<p>However this causes a problem with editors which cannot recognize comments or are not configured to do so because they cannot "bounce" around in the text correctly. The <b>-cscb</b> flag has been added to help them by appending appropriate balancing structure:</p>
-
-<pre><code> perltidy -csc -cscb
- } ## end foreach my $foo (sort { $b cmp $a ... })</code></pre>
-
-<p>The default is <b>-cscb</b>.</p>
-
-</dd>
-<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>
-<dd>
-
-<p>The default, <b>n=0</b>, places the text of the opening <code>if</code> statement after any terminal <code>else</code>.</p>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="cscb-or---closing-side-comments-balanced1"><b>-cscb</b>, or <b>--closing-side-comments-balanced</b></dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy -csc -ncscb
- } ## end foreach my $foo (sort { $b cmp $a ...</code></pre>
-
-<p>This causes a problem with older editors which do not recognize comments because they cannot "bounce" around in the text correctly. The <b>-cscb</b> flag tries to help them by appending appropriate terminal balancing structures:</p>
-
-<pre><code> perltidy -csc -cscb
- } ## end foreach my $foo (sort { $b cmp $a ... })</code></pre>
-
-<p>The default is <b>-cscb</b>.</p>
-
-</dd>
-<dt id="cscw-or---closing-side-comment-warnings"><b>-cscw</b>, or <b>--closing-side-comment-warnings</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-</dl>
-
-<p><b>Important Notes on Closing Side Comments:</b></p>
-
-<ul>
-
-<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>
-
-</li>
-<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>
-
-</li>
-<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>
-
-</li>
-<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>
-
-</li>
-<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>
-
-</li>
-<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>
-
-</li>
-</ul>
-
-</dd>
-<dt id="Static-Block-Comments">Static Block Comments</dt>
-<dd>
-
-<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>
-
-<dl>
-
-<dt id="sbc---static-block-comments"><b>-sbc</b>, <b>--static-block-comments</b></dt>
-<dd>
-
-<p>When <b>-sbc</b> is used, a block comment with a special leading pattern, <code>##</code> by default, will be treated specially.</p>
-
-<p>Comments so identified are treated as follows:</p>
-
-<ul>
-
-<li><p>If there is no leading space on the line, then the comment will not be indented, and otherwise it may be,</p>
-
-</li>
-<li><p>no new blank line will be inserted before such a comment, and</p>
-
-</li>
-<li><p>such a comment will never become a hanging side comment.</p>
-
-</li>
-</ul>
-
-<p>For example, assuming <code>@month_of_year</code> is left-adjusted:</p>
-
-<pre><code> @month_of_year = ( # -sbc (default)
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
- ## 'Dec', 'Nov'
- 'Nov', 'Dec');</code></pre>
-
-<p>Without this convention, the above code would become</p>
-
-<pre><code> @month_of_year = ( # -nsbc
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
-
- ## 'Dec', 'Nov'
- 'Nov', 'Dec'
- );</code></pre>
-
-<p>which is not as clear. The default is to use <b>-sbc</b>. This may be deactivated with <b>-nsbc</b>.</p>
-
-</dd>
-<dt id="sbcp-string---static-block-comment-prefix-string"><b>-sbcp=string</b>, <b>--static-block-comment-prefix=string</b></dt>
-<dd>
-
-<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='^#'</code>.</p>
-
-<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>
-
-<p>A pattern which can be useful is:</p>
-
-<pre><code> -sbcp=^#{2,}[^\s#] </code></pre>
-
-<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 '#' 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 '#'.</p>
-
-</dd>
-<dt id="osbc---outdent-static-block-comments"><b>-osbc</b>, <b>--outdent-static-block-comments</b></dt>
-<dd>
-
-<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>
-
-</dd>
-</dl>
-
-</dd>
-<dt id="Static-Side-Comments">Static Side Comments</dt>
-<dd>
-
-<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>
-
-<dl>
-
-<dt id="ssc---static-side-comments"><b>-ssc</b>, <b>--static-side-comments</b></dt>
-<dd>
-
-<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>
-
-<p>The default is <b>-nssc</b>.</p>
-
-</dd>
-<dt id="sscp-string---static-side-comment-prefix-string"><b>-sscp=string</b>, <b>--static-side-comment-prefix=string</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-</dl>
-
-</dd>
-</dl>
-
-<h2 id="Skipping-Selected-Sections-of-Code">Skipping Selected Sections of Code</h2>
-
-<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>
-
-<dl>
-
-<dt id="fs---format-skipping"><b>-fs</b>, <b>--format-skipping</b></dt>
-<dd>
-
-<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 #<<< and the default ending marker is #>>> 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>
-
-<pre><code> #<<< do not let perltidy touch this
- my @list = (1,
- 1, 1,
- 1, 2, 1,
- 1, 3, 3, 1,
- 1, 4, 6, 4, 1,);
- #>>></code></pre>
-
-<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>
-
-</dd>
-<dt id="fsb-string---format-skipping-begin-string"><b>-fsb=string</b>, <b>--format-skipping-begin=string</b></dt>
-<dd>
-
-<p>The <b>-fsb=string</b> parameter may be used to change the beginning marker for format skipping. The default is equivalent to -fsb='#<<<'. 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 '\s', so you must also include backslashes for characters to be taken literally rather than as patterns.</p>
-
-<p>Some examples show how example strings become patterns:</p>
-
-<pre><code> -fsb='#\{\{\{' becomes /^#\{\{\{\s/ which matches #{{{ but not #{{{{
- -fsb='#\*\*' becomes /^#\*\*\s/ which matches #** but not #***
- -fsb='#\*{2,}' becomes /^#\*{2,}\s/ which matches #** and #***** </code></pre>
-
-</dd>
-<dt id="fse-string---format-skipping-end-string"><b>-fse=string</b>, <b>--format-skipping-end=string</b></dt>
-<dd>
-
-<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='#<<<'.</p>
-
-</dd>
-</dl>
-
-<h2 id="Line-Break-Control">Line Break Control</h2>
-
-<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">"Blank Line Control"</a>.</p>
-
-<dl>
-
-<dt id="fnl---freeze-newlines"><b>-fnl</b>, <b>--freeze-newlines</b></dt>
-<dd>
-
-<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">"Controlling List Formatting"</a>, <a href="#Retaining-or-Ignoring-Existing-Line-Breaks">"Retaining or Ignoring Existing Line Breaks"</a>. You may want to use <b>-noll</b> with this.</p>
-
-<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">"Blank Line Control"</a>.</p>
-
-</dd>
-<dt id="ce---cuddled-else"><b>-ce</b>, <b>--cuddled-else</b></dt>
-<dd>
-
-<p>Enable the "cuddled else" 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>
-
-<pre><code> # -ce
- if ($task) {
- yyy();
- } else {
- zzz();
- }
-
- # -nce (default)
- if ($task) {
- yyy();
- }
- else {
- zzz();
- }</code></pre>
-
-<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 "cuddled" style are <b>elsif</b>, <b>continue</b>, <b>catch</b>, <b>finally</b>.</p>
-
-<p>Other block types can be formatted by specifying their names on a separate parameter <b>-cbl</b>, described in a later section.</p>
-
-<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>
-
-<p>So for example, the <b>-ce</b> flag would not have any effect if the above snippet is rewritten as</p>
-
-<pre><code> if ($task) { yyy() }
- else { zzz() }</code></pre>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="cb---cuddled-blocks"><b>-cb</b>, <b>--cuddled-blocks</b></dt>
-<dd>
-
-<p>This flag is equivalent to <b>-ce</b>.</p>
-
-</dd>
-<dt id="cbl---cuddled-block-list"><b>-cbl</b>, <b>--cuddled-block-list</b></dt>
-<dd>
-
-<p>The built-in default cuddled block types are <b>else, elsif, continue, catch, finally</b>.</p>
-
-<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>
-
-<pre><code> -cbl="sort map grep"</code></pre>
-
-<p>or equivalently</p>
-
-<pre><code> -cbl=sort,map,grep </code></pre>
-
-<p>Note however that these particular block types are typically short so there might not be much opportunity for the cuddled format style.</p>
-
-<p>Using commas avoids the need to protect spaces with quotes.</p>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="cblx---cuddled-block-list-exclusive"><b>-cblx</b>, <b>--cuddled-block-list-exclusive</b></dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy -ce -cbl='else elsif continue' -cblx</code></pre>
-
-</dd>
-<dt id="cbo-n---cuddled-break-option-n"><b>-cbo=n</b>, <b>--cuddled-break-option=n</b></dt>
-<dd>
-
-<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 "break" the block, meaning to cause it to span multiple lines. This parameter controls that decision. The options are:</p>
-
-<pre><code> cbo=0 Never force a short block to break.
- cbo=1 If the first of a pair of blocks is broken in the input file,
- then break the second [DEFAULT].
- cbo=2 Break open all blocks for maximal cuddled formatting.</code></pre>
-
-<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>
-
-<p>The option <b>cbo=0</b> can produce erratic cuddling if there are numerous one-line blocks.</p>
-
-<p>The option <b>cbo=2</b> produces maximal cuddling but will not allow any short blocks.</p>
-
-</dd>
-<dt id="bl---opening-brace-on-new-line"><b>-bl</b>, <b>--opening-brace-on-new-line</b></dt>
-<dd>
-
-<p>Use the flag <b>-bl</b> to place the opening brace on a new line:</p>
-
-<pre><code> if ( $input_file eq '-' ) # -bl
- {
- important_function();
- }</code></pre>
-
-<p>This flag applies to all structural blocks, including named sub's (unless the <b>-sbl</b> flag is set -- see next item).</p>
-
-<p>The default style, <b>-nbl</b>, places an opening brace on the same line as the keyword introducing it. For example,</p>
-
-<pre><code> if ( $input_file eq '-' ) { # -nbl (default)</code></pre>
-
-</dd>
-<dt id="sbl---opening-sub-brace-on-new-line"><b>-sbl</b>, <b>--opening-sub-brace-on-new-line</b></dt>
-<dd>
-
-<p>The flag <b>-sbl</b> can be used to override the value of <b>-bl</b> for the opening braces of named sub's. For example,</p>
-
-<pre><code> perltidy -sbl</code></pre>
-
-<p>produces this result:</p>
-
-<pre><code> sub message
- {
- if (!defined($_[0])) {
- print("Hello, World\n");
- }
- else {
- print($_[0], "\n");
- }
- }</code></pre>
-
-<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>
-
-</dd>
-<dt id="asbl---opening-anonymous-sub-brace-on-new-line"><b>-asbl</b>, <b>--opening-anonymous-sub-brace-on-new-line</b></dt>
-<dd>
-
-<p>The flag <b>-asbl</b> is like the <b>-sbl</b> flag except that it applies to anonymous sub's instead of named subs. For example</p>
-
-<pre><code> perltidy -asbl</code></pre>
-
-<p>produces this result:</p>
-
-<pre><code> $a = sub
- {
- if ( !defined( $_[0] ) ) {
- print("Hello, World\n");
- }
- else {
- print( $_[0], "\n" );
- }
- };</code></pre>
-
-<p>This flag is negated with <b>-nasbl</b>, and the default is <b>-nasbl</b>.</p>
-
-</dd>
-<dt id="bli---brace-left-and-indent"><b>-bli</b>, <b>--brace-left-and-indent</b></dt>
-<dd>
-
-<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>
-
-<p>For example,</p>
-
-<pre><code> if ( $input_file eq '-' ) # -bli
- {
- important_function();
- }</code></pre>
-
-<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>
-
-</dd>
-<dt id="blil-s---brace-left-and-indent-list-s"><b>-blil=s</b>, <b>--brace-left-and-indent-list=s</b></dt>
-<dd>
-
-<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">"Specifying Block Types"</a>. For example, <b>-blil='if elsif else'</b> would apply it to only <code>if/elsif/else</code> blocks.</p>
-
-</dd>
-<dt id="bar---opening-brace-always-on-right"><b>-bar</b>, <b>--opening-brace-always-on-right</b></dt>
-<dd>
-
-<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>
-
-<pre><code> if ( $bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4 )
- {
- big_waste_of_time();
- }</code></pre>
-
-<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>
-
-<pre><code> if ( $bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4 ) {
- big_waste_of_time();
- }</code></pre>
-
-<p>A conflict occurs if both <b>-bl</b> and <b>-bar</b> are specified.</p>
-
-</dd>
-<dt id="otr---opening-token-right-and-related-flags"><b>-otr</b>, <b>--opening-token-right</b> and related flags</dt>
-<dd>
-
-<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>
-
-<pre><code> # default formatting
- push @{ $self->{$module}{$key} },
- {
- accno => $ref->{accno},
- description => $ref->{description}
- };
-
- # perltidy -otr
- push @{ $self->{$module}{$key} }, {
- accno => $ref->{accno},
- description => $ref->{description}
- };</code></pre>
-
-<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>
-
-<pre><code> -opr or --opening-paren-right
- -ohbr or --opening-hash-brace-right
- -osbr or --opening-square-bracket-right</code></pre>
-
-</dd>
-<dt id="wn---weld-nested-containers"><b>-wn</b>, <b>--weld-nested-containers</b></dt>
-<dd>
-
-<p>The <b>-wn</b> flag causes closely nested pairs of opening and closing container symbols (curly braces, brackets, or parens) to be "welded" 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>
-
-<p>For example:</p>
-
-<pre><code> # default formatting
- do {
- {
- next if $x == $y;
- }
- } until $x++ > $z;
-
- # perltidy -wn
- do { {
- next if $x == $y;
- } } until $x++ > $z;</code></pre>
-
-<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>
-
-<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>
-
-<pre><code> # default formatting
- my (@date_time) = Localtime(
- Date_to_Time(
- Add_Delta_DHMS(
- $year, $month, $day, $hour, $minute, $second,
- '0', $offset, '0', '0'
- )
- )
- );
-
- # perltidy -wn
- my (@date_time) = Localtime( Date_to_Time( Add_Delta_DHMS(
- $year, $month, $day, $hour, $minute, $second,
- '0', $offset, '0', '0'
- ) ) );</code></pre>
-
-<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 "meat" of the sandwich, and a final closing layer. This predictable structure helps keep the compacted structure readable.</p>
-
-<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>
-
-<p>Here is an example illustrating a welded container within a welded containers:</p>
-
-<pre><code> # default formatting
- $x->badd(
- bmul(
- $class->new(
- abs(
- $sx * int( $xr->numify() ) & $sy * int( $yr->numify() )
- )
- ),
- $m
- )
- );
-
- # perltidy -wn
- $x->badd( bmul(
- $class->new( abs(
- $sx * int( $xr->numify() ) & $sy * int( $yr->numify() )
- ) ),
- $m
- ) );</code></pre>
-
-<p>This format option is quite general but there are some limitations.</p>
-
-<p>One limitiation is that any line length limit still applies and can cause long welded sections to be broken into multiple lines.</p>
-
-<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>
-
-<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>
-
-</dd>
-<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>
-<dd>
-
-<p>These parameters control what shall be called vertical tightness. Here are the main points:</p>
-
-<ul>
-
-<li><p>Opening tokens (except for block braces) are controlled by <b>-vt=n</b>, or <b>--vertical-tightness=n</b>, where</p>
-
-<pre><code> -vt=0 always break a line after opening token (default).
- -vt=1 do not break unless this would produce more than one
- step in indentation in a line.
- -vt=2 never break a line after opening token</code></pre>
-
-</li>
-<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>
-
-</li>
-<li><p>Closing tokens (except for block braces) are controlled by <b>-vtc=n</b>, or <b>--vertical-tightness-closing=n</b>, where</p>
-
-<pre><code> -vtc=0 always break a line before a closing token (default),
- -vtc=1 do not break before a closing token which is followed
- by a semicolon or another closing token, and is not in
- a list environment.
- -vtc=2 never break before a closing token.</code></pre>
-
-<p>The rules for <b>-vtc=1</b> are designed to maintain a reasonable balance between tightness and readability in complex lists.</p>
-
-</li>
-<li><p>Different controls may be applied to different token types, and it is also possible to control block braces; see below.</p>
-
-</li>
-<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>
-
-</li>
-</ul>
-
-<p>Here are some examples:</p>
-
-<pre><code> # perltidy -lp -vt=0 -vtc=0
- %romanNumerals = (
- one => 'I',
- two => 'II',
- three => 'III',
- four => 'IV',
- );
-
- # perltidy -lp -vt=1 -vtc=0
- %romanNumerals = ( one => 'I',
- two => 'II',
- three => 'III',
- four => 'IV',
- );
-
- # perltidy -lp -vt=1 -vtc=1
- %romanNumerals = ( one => 'I',
- two => 'II',
- three => 'III',
- four => 'IV', );</code></pre>
-
-<p>The difference between <b>-vt=1</b> and <b>-vt=2</b> is shown here:</p>
-
-<pre><code> # perltidy -lp -vt=1
- $init->add(
- mysprintf( "(void)find_threadsv(%s);",
- cstring( $threadsv_names[ $op->targ ] )
- )
- );
-
- # perltidy -lp -vt=2
- $init->add( mysprintf( "(void)find_threadsv(%s);",
- cstring( $threadsv_names[ $op->targ ] )
- )
- );</code></pre>
-
-<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>
-
-<p>The tightest, and least readable, code is produced with both <code>-vt=2</code> and <code>-vtc=2</code>:</p>
-
-<pre><code> # perltidy -lp -vt=2 -vtc=2
- $init->add( mysprintf( "(void)find_threadsv(%s);",
- cstring( $threadsv_names[ $op->targ ] ) ) );</code></pre>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="bbvt-n-or---block-brace-vertical-tightness-n"><b>-bbvt=n</b> or <b>--block-brace-vertical-tightness=n</b></dt>
-<dd>
-
-<p>The <b>-bbvt=n</b> flag is just like the <b>-vt=n</b> flag but applies to opening code block braces.</p>
-
-<pre><code> -bbvt=0 break after opening block brace (default).
- -bbvt=1 do not break unless this would produce more than one
- step in indentation in a line.
- -bbvt=2 do not break after opening block brace.</code></pre>
-
-<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>
-
-<pre><code> # perltidy -bli -bbvt=0
- if ( open( FILE, "< $File" ) )
- {
- while ( $File = <FILE> )
- {
- $In .= $File;
- $count++;
- }
- close(FILE);
- }
-
- # perltidy -bli -bbvt=1
- if ( open( FILE, "< $File" ) )
- { while ( $File = <FILE> )
- { $In .= $File;
- $count++;
- }
- close(FILE);
- }</code></pre>
-
-<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">"Specifying Block Types"</a></p>
-
-<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='if elsif else'</code>.</p>
-
-<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>
-
-</dd>
-<dt id="sot---stack-opening-tokens-and-related-flags"><b>-sot</b>, <b>--stack-opening-tokens</b> and related flags</dt>
-<dd>
-
-<p>The <b>-sot</b> flag tells perltidy to "stack" opening tokens when possible to avoid lines with isolated opening tokens.</p>
-
-<p>For example:</p>
-
-<pre><code> # default
- $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );
-
- # -sot
- $opt_c = Text::CSV_XS->new( {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );</code></pre>
-
-<p>For detailed control of individual closing tokens the following controls can be used:</p>
-
-<pre><code> -sop or --stack-opening-paren
- -sohb or --stack-opening-hash-brace
- -sosb or --stack-opening-square-bracket
- -sobb or --stack-opening-block-brace</code></pre>
-
-<p>The flag <b>-sot</b> is an abbreviation for <b>-sop -sohb -sosb</b>.</p>
-
-<p>The flag <b>-sobb</b> is a abbreviation for <b>-bbvt=2 -bbvtl='*'</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>
-
-</dd>
-<dt id="sct---stack-closing-tokens-and-related-flags"><b>-sct</b>, <b>--stack-closing-tokens</b> and related flags</dt>
-<dd>
-
-<p>The <b>-sct</b> flag tells perltidy to "stack" closing tokens when possible to avoid lines with isolated closing tokens.</p>
-
-<p>For example:</p>
-
-<pre><code> # default
- $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );
-
- # -sct
- $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- } );</code></pre>
-
-<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 "hiding" 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>
-
-<pre><code> # -vtc=2
- $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1, } );</code></pre>
-
-<p>For detailed control of the stacking of individual closing tokens the following controls can be used:</p>
-
-<pre><code> -scp or --stack-closing-paren
- -schb or --stack-closing-hash-brace
- -scsb or --stack-closing-square-bracket
- -scbb or --stack-closing-block-brace</code></pre>
-
-<p>The flag <b>-sct</b> is an abbreviation for stacking the non-block closing tokens, <b>-scp -schb -scsb</b>.</p>
-
-<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>
-
-<pre><code> # -scbb:
- for $w1 (@w1) {
- for $w2 (@w2) {
- for $w3 (@w3) {
- for $w4 (@w4) {
- push( @lines, "$w1 $w2 $w3 $w4\n" );
- } } } }</code></pre>
-
-<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>
-
-</dd>
-<dt id="dnl---delete-old-newlines"><b>-dnl</b>, <b>--delete-old-newlines</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="anl---add-newlines"><b>-anl</b>, <b>--add-newlines</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="Controlling-whether-perltidy-breaks-before-or-after-operators">Controlling whether perltidy breaks before or after operators</dt>
-<dd>
-
-<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>
-
-<p><b>-wba=s</b> or <b>--want-break-after=s</b>, and</p>
-
-<p><b>-wbb=s</b> or <b>--want-break-before=s</b>.</p>
-
-<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>
-
-<p>By default, perltidy breaks <b>after</b> these token types: % + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=</p>
-
-<p>And perltidy breaks <b>before</b> these token types by default: . << >> -> && || //</p>
-
-<p>To illustrate, to cause a break after a concatenation operator, <code>'.'</code>, rather than before it, the command line would be</p>
-
-<pre><code> -wba="."</code></pre>
-
-<p>As another example, the following command would cause a break before math operators <code>'+'</code>, <code>'-'</code>, <code>'/'</code>, and <code>'*'</code>:</p>
-
-<pre><code> -wbb="+ - / *"</code></pre>
-
-<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>
-
-<p><b>WARNING</b> Be sure to put these tokens in quotes to avoid having them misinterpreted by your command shell.</p>
-
-<p>Two additional parameters are available which, though they provide no further capability, can simplify input are:</p>
-
-<p><b>-baao</b> or <b>--break-after-all-operators</b>,</p>
-
-<p><b>-bbao</b> or <b>--break-before-all-operators</b>.</p>
-
-<p>The -baao sets the default to be to break after all of the following operators:</p>
-
-<pre><code> % + - * / x != == >= <= =~ !~ < > | &
- = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
- . : ? && || and or err xor</code></pre>
-
-<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='=' rather than listing every single perl operator except <b>=</b> on a -wbb flag.</p>
-
-</dd>
-</dl>
-
-<h2 id="Controlling-List-Formatting">Controlling List Formatting</h2>
-
-<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>
-
-<dl>
-
-<dt id="boc---break-at-old-comma-breakpoints"><b>-boc</b>, <b>--break-at-old-comma-breakpoints</b></dt>
-<dd>
-
-<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>
-
-<pre><code> my @list = (1,
- 1, 1,
- 1, 2, 1,
- 1, 3, 3, 1,
- 1, 4, 6, 4, 1,);</code></pre>
-
-<p>The default formatting will flatten this down to one line:</p>
-
-<pre><code> # perltidy (default)
- my @list = ( 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1, );</code></pre>
-
-<p>which hides the structure. Using <b>-boc</b>, plus additional flags to retain the original style, yields</p>
-
-<pre><code> # perltidy -boc -lp -pt=2 -vt=1 -vtc=1
- my @list = (1,
- 1, 1,
- 1, 2, 1,
- 1, 3, 3, 1,
- 1, 4, 6, 4, 1,);</code></pre>
-
-<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">"Skipping Selected Sections of Code"</a>.</p>
-
-</dd>
-<dt id="mft-n---maximum-fields-per-table-n"><b>-mft=n</b>, <b>--maximum-fields-per-table=n</b></dt>
-<dd>
-
-<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>
-
-<pre><code> # perltidy -mft=2
- @month_of_year = (
- 'Jan', 'Feb',
- 'Mar', 'Apr',
- 'May', 'Jun',
- 'Jul', 'Aug',
- 'Sep', 'Oct',
- 'Nov', 'Dec'
- );</code></pre>
-
-</dd>
-<dt id="cab-n---comma-arrow-breakpoints-n"><b>-cab=n</b>, <b>--comma-arrow-breakpoints=n</b></dt>
-<dd>
-
-<p>A comma which follows a comma arrow, '=>', 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>
-
-<pre><code> n=0 break at all commas after =>
- n=1 stable: break at all commas after => if container is open,
- EXCEPT FOR one-line containers
- n=2 break at all commas after =>, BUT try to form the maximum
- maximum one-line container lengths
- n=3 do not treat commas after => specially at all
- n=4 break everything: like n=0 but ALSO break a short container with
- a => not followed by a comma when -vt=0 is used
- n=5 stable: like n=1 but ALSO break at open one-line containers when
- -vt=0 is used (default)</code></pre>
-
-<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>
-
-<pre><code> bless { B => $B, Root => $Root } => $package;</code></pre>
-
-<p>Using <b>-cab=0</b> will force a break after each comma-arrow item:</p>
-
-<pre><code> # perltidy -cab=0:
- bless {
- B => $B,
- Root => $Root
- } => $package;</code></pre>
-
-<p>If perltidy is subsequently run with this container broken, then by default it will break after each '=>' because the container is now broken. To reform a one-line container, the parameter <b>-cab=2</b> could be used.</p>
-
-<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 "01" => 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>
-
-<pre><code> # perltidy -cab=3
- my %last_day = (
- "01" => 31, "02" => 29, "03" => 31, "04" => 30,
- "05" => 31, "06" => 30, "07" => 31, "08" => 31,
- "09" => 30, "10" => 31, "11" => 30, "12" => 31
- );</code></pre>
-
-</dd>
-</dl>
-
-<h2 id="Retaining-or-Ignoring-Existing-Line-Breaks">Retaining or Ignoring Existing Line Breaks</h2>
-
-<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>
-
-<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>
-
-<dl>
-
-<dt id="bol---break-at-old-logical-breakpoints"><b>-bol</b>, <b>--break-at-old-logical-breakpoints</b></dt>
-<dd>
-
-<p>By default, if a logical expression is broken at a <code>&&</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>
-
-</dd>
-<dt id="bok---break-at-old-keyword-breakpoints"><b>-bok</b>, <b>--break-at-old-keyword-breakpoints</b></dt>
-<dd>
-
-<p>By default, perltidy will retain a breakpoint before keywords which may return lists, such as <code>sort</code> and <map>. This allows chains of these operators to be displayed one per line. Use <b>-nbok</b> to prevent retaining these breakpoints.</p>
-
-</dd>
-<dt id="bot---break-at-old-ternary-breakpoints"><b>-bot</b>, <b>--break-at-old-ternary-breakpoints</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="boa---break-at-old-attribute-breakpoints"><b>-boa</b>, <b>--break-at-old-attribute-breakpoints</b></dt>
-<dd>
-
-<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 ':'s will be retained:</p>
-
-<pre><code> my @field
- : field
- : Default(1)
- : Get('Name' => 'foo') : Set('Name');</code></pre>
-
-<p>If the attributes are on a single line in the source code then they will remain on a single line if possible.</p>
-
-<p>To prevent this, and thereby always form longer lines, use <b>-nboa</b>.</p>
-
-</dd>
-<dt id="iob---ignore-old-breakpoints"><b>-iob</b>, <b>--ignore-old-breakpoints</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="kis---keep-interior-semicolons"><b>-kis</b>, <b>--keep-interior-semicolons</b></dt>
-<dd>
-
-<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>
-
-<pre><code> dbmclose(%verb_delim); undef %verb_delim;
- dbmclose(%expanded); undef %expanded;</code></pre>
-
-<p>The default is to break after each statement, giving</p>
-
-<pre><code> dbmclose(%verb_delim);
- undef %verb_delim;
- dbmclose(%expanded);
- undef %expanded;</code></pre>
-
-<p>With <b>perltidy -kis</b> the multiple statements are retained:</p>
-
-<pre><code> dbmclose(%verb_delim); undef %verb_delim;
- dbmclose(%expanded); undef %expanded;</code></pre>
-
-<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>
-
-</dd>
-</dl>
-
-<h2 id="Blank-Line-Control">Blank Line Control</h2>
-
-<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>
-
-<dl>
-
-<dt id="fbl---freeze-blank-lines"><b>-fbl</b>, <b>--freeze-blank-lines</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="bbc---blanks-before-comments"><b>-bbc</b>, <b>--blanks-before-comments</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="blbs-n---blank-lines-before-subs-n"><b>-blbs=n</b>, <b>--blank-lines-before-subs=n</b></dt>
-<dd>
-
-<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 <-blbs=1>. <b>BEGIN</b> and <b>END</b> blocks are included.</p>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="blbp-n---blank-lines-before-packages-n"><b>-blbp=n</b>, <b>--blank-lines-before-packages=n</b></dt>
-<dd>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="bbs---blanks-before-subs"><b>-bbs</b>, <b>--blanks-before-subs</b></dt>
-<dd>
-
-<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>
-
-<p>Likewise, <b>-nbbs</b> or <b>--noblanks-before-subs</b> is equivalent to <i>-blbp=0</i> and <i>-blbs=0</i>.</p>
-
-</dd>
-<dt id="bbb---blanks-before-blocks"><b>-bbb</b>, <b>--blanks-before-blocks</b></dt>
-<dd>
-
-<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>
-
-<ul>
-
-<li><p>The block is not preceded by a comment.</p>
-
-</li>
-<li><p>The block is not a one-line block.</p>
-
-</li>
-<li><p>The number of consecutive non-blank lines at the current indentation depth is at least <b>-lbl</b> (see next section).</p>
-
-</li>
-</ul>
-
-<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>
-
-</dd>
-<dt id="lbl-n---long-block-line-count-n"><b>-lbl=n</b> <b>--long-block-line-count=n</b></dt>
-<dd>
-
-<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>
-
-</dd>
-<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>
-<dd>
-
-<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>
-
-<p>Please see the note below on using the <b>-blao</b> and <b>-blbc</b> options.</p>
-
-</dd>
-<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>
-<dd>
-
-<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>
-
-</dd>
-<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>
-<dd>
-
-<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">"Specifying Block Types"</a> explains how to list block types.</p>
-
-</dd>
-<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>
-<dd>
-
-<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">"Specifying Block Types"</a> explains how to list block types.</p>
-
-</dd>
-<dt id="Note-on-using-the--blao-and--blbc-options">Note on using the <b>-blao</b> and <b>-blbc</b> options.</dt>
-<dd>
-
-<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>
-
-<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>
-
-<pre><code> perltidy -blao=2 -blbc=2 -blaol='*' -blbcl='*' filename</code></pre>
-
-<p>Now suppose the script continues to be developed, but at some later date we decide we don'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>
-
-<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>
-
-</dd>
-<dt id="mbl-n---maximum-consecutive-blank-lines-n"><b>-mbl=n</b> <b>--maximum-consecutive-blank-lines=n</b></dt>
-<dd>
-
-<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>
-
-<p>This flag obviously does not apply to pod sections, here-documents, and quotes.</p>
-
-</dd>
-<dt id="kbl-n---keep-old-blank-lines-n"><b>-kbl=n</b>, <b>--keep-old-blank-lines=n</b></dt>
-<dd>
-
-<p>The <b>-kbl=n</b> flag gives you control over how your existing blank lines are treated.</p>
-
-<p>The possible values of <b>n</b> are:</p>
-
-<pre><code> n=0 ignore all old blank lines
- n=1 stable: keep old blanks, but limited by the value of the B<-mbl=n> flag
- n=2 keep all old blank lines, regardless of the value of the B<-mbl=n> flag</code></pre>
-
-<p>The default is <b>n=1</b>.</p>
-
-</dd>
-<dt id="sob---swallow-optional-blank-lines"><b>-sob</b>, <b>--swallow-optional-blank-lines</b></dt>
-<dd>
-
-<p>This is equivalent to <b>kbl=0</b> and is included for compatibility with previous versions.</p>
-
-</dd>
-<dt id="nsob---noswallow-optional-blank-lines"><b>-nsob</b>, <b>--noswallow-optional-blank-lines</b></dt>
-<dd>
-
-<p>This is equivalent to <b>kbl=1</b> and is included for compatibility with previous versions.</p>
-
-</dd>
-</dl>
-
-<h2 id="Styles">Styles</h2>
-
-<p>A style refers to a convenient collection of existing parameters.</p>
-
-<dl>
-
-<dt id="gnu---gnu-style"><b>-gnu</b>, <b>--gnu-style</b></dt>
-<dd>
-
-<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>
-
-<pre><code> -lp -bl -noll -pt=2 -bt=2 -sbt=2 -icp</code></pre>
-
-</dd>
-<dt id="pbp---perl-best-practices"><b>-pbp</b>, <b>--perl-best-practices</b></dt>
-<dd>
-
-<p><b>-pbp</b> is an abbreviation for the parameters in the book <b>Perl Best Practices</b> by Damian Conway:</p>
-
-<pre><code> -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
- -wbb="% + - * / x != == >= <= =~ !~ < > | & =
- **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="</code></pre>
-
-<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>
-
-<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>
-
-<pre><code> # perltidy -pbp
- $self->{_text} = (
- !$section ? ''
- : $type eq 'item' ? "the $section entry"
- : "the section on $section"
- )
- . (
- $page
- ? ( $section ? ' in ' : '' ) . "the $page$page_ext manpage"
- : ' elsewhere in this document'
- );
-
- # perltidy -pbp -ci=2
- $self->{_text} = (
- !$section ? ''
- : $type eq 'item' ? "the $section entry"
- : "the section on $section"
- )
- . (
- $page
- ? ( $section ? ' in ' : '' ) . "the $page$page_ext manpage"
- : ' elsewhere in this document'
- );</code></pre>
-
-</dd>
-</dl>
-
-<h2 id="Controlling-Vertical-Alignment">Controlling Vertical Alignment</h2>
-
-<p>Vertical alignment refers to lining up certain symbols in list of consecutive similar lines to improve readability. For example, the "fat commas" are aligned in the following statement:</p>
-
-<pre><code> $data = $pkg->new(
- PeerAddr => join( ".", @port[ 0 .. 3 ] ),
- PeerPort => $port[4] * 256 + $port[5],
- Proto => 'tcp'
- );</code></pre>
-
-<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>
-
-<pre><code> %option_range = (
- 'format' => [ 'tidy', 'html', 'user' ],
- 'output-line-ending' => [ 'dos', 'win', 'mac', 'unix' ],
- 'character-encoding' => [ 'none', 'utf8' ],
-
- 'block-brace-tightness' => [ 0, 2 ],
- 'brace-tightness' => [ 0, 2 ],
- 'paren-tightness' => [ 0, 2 ],
- 'square-bracket-tightness' => [ 0, 2 ],
- );</code></pre>
-
-<h2 id="Other-Controls">Other Controls</h2>
-
-<dl>
-
-<dt id="Deleting-selected-text">Deleting selected text</dt>
-<dd>
-
-<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>
-
-<p>The command <b>-dp</b> or <b>--delete-pod</b> will remove all pod documentation (but not comments).</p>
-
-<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>
-
-<p>The negatives of these commands also work, and are the defaults. When block comments are deleted, any leading 'hash-bang' 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>
-
-</dd>
-<dt id="Writing-selected-text-to-a-file">Writing selected text to a file</dt>
-<dd>
-
-<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>
-
-<p>The command <b>-tac</b> or <b>--tee-all-comments</b> will write all comments <b>and</b> all pod documentation.</p>
-
-<p>The command <b>-tp</b> or <b>--tee-pod</b> will write all pod documentation (but not comments).</p>
-
-<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>
-
-<p>The negatives of these commands also work, and are the defaults.</p>
-
-</dd>
-<dt id="Using-a-.perltidyrc-command-file">Using a <i>.perltidyrc</i> command file</dt>
-<dd>
-
-<p>If you use perltidy frequently, you probably won'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>
-
-<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>
-
-<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>
-
-<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>
-
-<p>http://www.netmanage.com/000/20021101_005_tcm21-6336.pdf</p>
-
-<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>
-
-<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>
-
-<p>Here is an example of a <i>.perltidyrc</i> file:</p>
-
-<pre><code> # This is a simple of a .perltidyrc configuration file
- # This implements a highly spaced style
- -se # errors to standard error output
- -w # show all warnings
- -bl # braces on new lines
- -pt=0 # parens not tight at all
- -bt=0 # braces not tight
- -sbt=0 # square brackets not tight</code></pre>
-
-<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>
-
-<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>
-
-<pre><code> -h -v -ddf -dln -dop -dsn -dtt -dwls -dwrs -ss</code></pre>
-
-<p>There are several options may be helpful in debugging a <i>.perltidyrc</i> file:</p>
-
-<ul>
-
-<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>
-
-<pre><code> perltidy -dpro</code></pre>
-
-</li>
-<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>
-
-</li>
-<li><p>The parameters in the <i>.perltidyrc</i> file can be switched off with the <b>-npro</b> option.</p>
-
-</li>
-<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>
-
-</li>
-</ul>
-
-</dd>
-<dt id="Creating-a-new-abbreviation">Creating a new abbreviation</dt>
-<dd>
-
-<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>
-
-<pre><code> newword {
- -opt1
- -opt2
- }</code></pre>
-
-<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>
-
-<pre><code> airy {-bl -pt=0 -bt=0 -sbt=0}</code></pre>
-
-<p>could be placed in a <i>.perltidyrc</i> file, and then invoked at will with</p>
-
-<pre><code> perltidy -airy somefile.pl</code></pre>
-
-<p>(Either <code>-airy</code> or <code>--airy</code> may be used).</p>
-
-</dd>
-<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>
-<dd>
-
-<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 "hash-bang" 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 "hash-bang" 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>
-
-</dd>
-<dt id="Making-a-file-unreadable">Making a file unreadable</dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy --mangle myfile.pl -st | perltidy -o myfile.pl.new</code></pre>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="One-line-blocks">One-line blocks</dt>
-<dd>
-
-<p>There are a few points to note regarding one-line blocks. A one-line block is something like this,</p>
-
-<pre><code> if ($x > 0) { $y = 1 / $x } </code></pre>
-
-<p>where the contents within the curly braces is short enough to fit on a single line.</p>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="Debugging">Debugging</dt>
-<dd>
-
-<p>The following flags are available for debugging:</p>
-
-<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>
-
-<p><b>--dump-defaults</b> or <b>-ddf</b> will write the default option set to standard output and quit</p>
-
-<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>
-
-<p><b>--dump-options</b> or <b>-dop</b> will write current option set to standard output and quit.</p>
-
-<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>
-
-<p><b>--dump-short-names</b> or <b>-dsn</b> will write all command line short names to standard output and quit.</p>
-
-<p><b>--dump-token-types</b> or <b>-dtt</b> will write a list of all token types to standard output and quit.</p>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="Working-with-MakeMaker-AutoLoader-and-SelfLoader">Working with MakeMaker, AutoLoader and SelfLoader</dt>
-<dd>
-
-<p>The first $VERSION line of a file which might be eval'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>
-
-<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>
-
-<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>
-
-</dd>
-<dt id="Working-around-problems-with-older-version-of-Perl">Working around problems with older version of Perl</dt>
-<dd>
-
-<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>
-
-<p>There is no way to override these rules.</p>
-
-</dd>
-</dl>
-
-<h1 id="HTML-OPTIONS">HTML OPTIONS</h1>
-
-<dl>
-
-<dt id="The--html-master-switch">The <b>-html</b> master switch</dt>
-<dd>
-
-<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>
-
-<pre><code> perltidy -html somefile.pl</code></pre>
-
-<p>will produce a syntax-colored html file named <i>somefile.pl.html</i> which may be viewed with a browser.</p>
-
-<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>
-
-</dd>
-<dt id="The--pre-flag-for-code-snippets">The <b>-pre</b> flag for code snippets</dt>
-<dd>
-
-<p>When the <b>-pre</b> flag is given, only the pre-formatted section, within the <PRE> and </PRE> tags, will be output. This simplifies inclusion of the output in other files. The default is to output a complete web page.</p>
-
-</dd>
-<dt id="The--nnn-flag-for-line-numbering">The <b>-nnn</b> flag for line numbering</dt>
-<dd>
-
-<p>When the <b>-nnn</b> flag is given, the output lines will be numbered.</p>
-
-</dd>
-<dt id="The--toc-or---html-table-of-contents-flag">The <b>-toc</b>, or <b>--html-table-of-contents</b> flag</dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="The--pod-or---pod2html-flag">The <b>-pod</b>, or <b>--pod2html</b> flag</dt>
-<dd>
-
-<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">"FILES"</a>. Also, Pod::Html creates temporary files for its cache.</p>
-
-<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>
-
-<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>
-
-<pre><code> --[no]podheader --[no]podindex --[no]podrecurse --[no]podquiet
- --[no]podverbose --podflush</code></pre>
-
-<p>The flags which are unchanged from their use in pod2html are:</p>
-
-<pre><code> --backlink=s --cachedir=s --htmlroot=s --libpods=s --title=s
- --podpath=s --podroot=s </code></pre>
-
-<p>where 's' 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>
-
-<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>
-
-</dd>
-<dt id="The--frm-or---frames-flag">The <b>-frm</b>, or <b>--frames</b> flag</dt>
-<dd>
-
-<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>
-
-<pre><code> MyModule.pm.html - the frame
- MyModule.pm.toc.html - the table of contents
- MyModule.pm.src.html - the formatted source code</code></pre>
-
-<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>
-
-</dd>
-<dt id="The--text-s-or---html-toc-extension-flag">The <b>-text=s</b>, or <b>--html-toc-extension</b> flag</dt>
-<dd>
-
-<p>Use this flag to specify the extra file extension of the table of contents file when html frames are used. The default is "toc". See <a href="#Specifying-File-Extensions">"Specifying File Extensions"</a>.</p>
-
-</dd>
-<dt id="The--sext-s-or---html-src-extension-flag">The <b>-sext=s</b>, or <b>--html-src-extension</b> flag</dt>
-<dd>
-
-<p>Use this flag to specify the extra file extension of the content file when html frames are used. The default is "src". See <a href="#Specifying-File-Extensions">"Specifying File Extensions"</a>.</p>
-
-</dd>
-<dt id="The--hent-or---html-entities-flag">The <b>-hent</b>, or <b>--html-entities</b> flag</dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Style-Sheets">Style Sheets</dt>
-<dd>
-
-<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>
-
-<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>
-
-<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>
-
-<pre><code> perltidy -html -ss >mystyle.css</code></pre>
-
-<p>will write a style sheet with the default properties to file <i>mystyle.css</i>.</p>
-
-<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>
-
-</dd>
-<dt id="Controlling-HTML-properties">Controlling HTML properties</dt>
-<dd>
-
-<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>
-
-<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>
-
-<pre><code> Token Type xxxxxx x
- ---------- -------- --
- comment comment c
- number numeric n
- identifier identifier i
- bareword, function bareword w
- keyword keyword k
- quite, pattern quote q
- here doc text here-doc-text h
- here doc target here-doc-target hh
- punctuation punctuation pu
- parentheses paren p
- structural braces structure s
- semicolon semicolon sc
- colon colon co
- comma comma cm
- label label j
- sub definition name subroutine m
- pod text pod-text pd</code></pre>
-
-<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 'red'.</p>
-
-<p>To illustrate, the following command will produce an html file <i>somefile.pl.html</i> with "aqua" keywords:</p>
-
-<pre><code> perltidy -html -hck=00ffff somefile.pl</code></pre>
-
-<p>and this should be equivalent for most browsers:</p>
-
-<pre><code> perltidy -html -hck=aqua somefile.pl</code></pre>
-
-<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>
-
-<pre><code> black => 000000,
- silver => c0c0c0,
- gray => 808080,
- white => ffffff,
- maroon => 800000,
- red => ff0000,
- purple => 800080,
- fuchsia => ff00ff,
- green => 008000,
- lime => 00ff00,
- olive => 808000,
- yellow => ffff00
- navy => 000080,
- blue => 0000ff,
- teal => 008080,
- aqua => 00ffff,</code></pre>
-
-<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 "HTML color tables".</p>
-
-<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>
-
-<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>
-
-<p>For example, to use bold braces and lime color, non-bold, italics keywords the following command would be used:</p>
-
-<pre><code> perltidy -html -hbs -hck=00FF00 -nhbk -hik somefile.pl</code></pre>
-
-<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>
-
-<p>Here are some notes and hints:</p>
-
-<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>
-
-<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>
-
-<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>
-
-</dd>
-</dl>
-
-<h1 id="SOME-COMMON-INPUT-CONVENTIONS">SOME COMMON INPUT CONVENTIONS</h1>
-
-<h2 id="Specifying-Block-Types">Specifying Block Types</h2>
-
-<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>'*'</b>.</p>
-
-<p>The keyword <b>sub</b> indicates a named sub. For anonymous subs, use the special keyword <b>asub</b>.</p>
-
-<p>For example, the following parameter specifies <code>sub</code>, labels, <code>BEGIN</code>, and <code>END</code> blocks:</p>
-
-<pre><code> -cscl="sub : BEGIN END"</code></pre>
-
-<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>
-
-<pre><code> -bbvtl='*'</code></pre>
-
-<h2 id="Specifying-File-Extensions">Specifying File Extensions</h2>
-
-<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 '.' 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 '.' (or perhaps an '_' on VMS systems). Otherwise, it will be appended directly.</p>
-
-<p>For example, suppose the file is <i>somefile.pl</i>. For <code>-bext=old</code>, a '.' is added to give <i>somefile.pl.old</i>. For <code>-bext=.old</code>, no additional '.' 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>
-
-<h1 id="SWITCHES-WHICH-MAY-BE-NEGATED">SWITCHES WHICH MAY BE NEGATED</h1>
-
-<p>The following list shows all short parameter names which allow a prefix 'n' to produce the negated form:</p>
-
-<pre><code> D anl asc aws b bbb bbc bbs bl bli boc bok bol bot ce
- csc dac dbc dcsc ddf dln dnl dop dp dpro dsc dsm dsn dtt dwls
- dwrs dws f fll frm fs hsc html ibc icb icp iob isbc lal log
- lp lsl ohbr okw ola oll opr opt osbr otr ple pod pvl q
- sbc sbl schb scp scsb sct se sfp sfs skp sob sohb sop sosb sot
- ssc st sts syn t tac tbc toc tp tqw tsc w x bar kis</code></pre>
-
-<p>Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used.</p>
-
-<h1 id="LIMITATIONS">LIMITATIONS</h1>
-
-<dl>
-
-<dt id="Parsing-Limitations">Parsing Limitations</dt>
-<dd>
-
-<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>
-
-<p>The main current limitation is that perltidy does not scan modules included with 'use' 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>
-
-<p>If you encounter a bug, please report it.</p>
-
-</dd>
-<dt id="What-perltidy-does-not-parse-and-format">What perltidy does not parse and format</dt>
-<dd>
-
-<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 'format' sections in any way. And, of course, it does not modify pod documents.</p>
-
-</dd>
-</dl>
-
-<h1 id="FILES">FILES</h1>
-
-<dl>
-
-<dt id="Temporary-files">Temporary files</dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Special-files-when-standard-input-is-used">Special files when standard input is used</dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Files-overwritten">Files overwritten</dt>
-<dd>
-
-<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>
-
-</dd>
-<dt id="Files-extensions-limitations">Files extensions limitations</dt>
-<dd>
-
-<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>
-
-</dd>
-</dl>
-
-<h1 id="SEE-ALSO">SEE ALSO</h1>
-
-<p>perlstyle(1), Perl::Tidy(3)</p>
-
-<h1 id="VERSION">VERSION</h1>
-
-<p>This man page documents perltidy version 20180220.01</p>
-
-<h1 id="BUG-REPORTS">BUG REPORTS</h1>
-
-<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>
-
-<p>To report a new bug or problem, use the link on this page.</p>
-
-<p>The source code repository is at <a href="https://github.com/perltidy/perltidy">https://github.com/perltidy/perltidy</a>.</p>
-
-<h1 id="COPYRIGHT">COPYRIGHT</h1>
-
-<p>Copyright (c) 2000-2018 by Steve Hancock</p>
-
-<h1 id="LICENSE">LICENSE</h1>
-
-<p>This package is free software; you can redistribute it and/or modify it under the terms of the "GNU General Public License".</p>
-
-<p>Please refer to the file "COPYING" for details.</p>
-
-<h1 id="DISCLAIMER">DISCLAIMER</h1>
-
-<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>
-
-<p>See the "GNU General Public License" for more details.</p>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# NAME
+
+perltidy - a perl script indenter and reformatter
+
+# SYNOPSIS
+
+ perltidy [ options ] file1 file2 file3 ...
+ (output goes to file1.tdy, file2.tdy, file3.tdy, ...)
+ perltidy [ options ] file1 -o outfile
+ perltidy [ options ] file1 -st >outfile
+ perltidy [ options ] <infile >outfile
+
+# DESCRIPTION
+
+Perltidy reads a perl script and writes an indented, reformatted script.
+
+Many users will find enough information in ["EXAMPLES"](#examples) to get
+started. New users may benefit from the short tutorial
+which can be found at
+http://perltidy.sourceforge.net/tutorial.html
+
+A convenient aid to systematically defining a set of style parameters
+can be found at
+http://perltidy.sourceforge.net/stylekey.html
+
+Perltidy can produce output on either of two modes, depending on the
+existence of an **-html** 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 ["FORMATTING
+OPTIONS"](#formatting-options).
+
+When the **-html** flag is given, the output is passed through an HTML
+formatter which is described in ["HTML OPTIONS"](#html-options).
+
+# EXAMPLES
+
+ perltidy somefile.pl
+
+This will produce a file `somefile.pl.tdy` containing the script reformatted
+using the default options, which approximate the style suggested in
+perlstyle(1). The source file `somefile.pl` is unchanged.
+
+ perltidy *.pl
+
+Execute perltidy on all `.pl` files in the current directory with the
+default options. The output will be in files with an appended `.tdy`
+extension. For any file with an error, there will be a file with extension
+`.ERR`.
+
+ perltidy -b file1.pl file2.pl
+
+Modify `file1.pl` and `file2.pl` in place, and backup the originals to
+`file1.pl.bak` and `file2.pl.bak`. If `file1.pl.bak` and/or `file2.pl.bak`
+already exist, they will be overwritten.
+
+ perltidy -b -bext='/' file1.pl file2.pl
+
+Same as the previous example except that the backup files `file1.pl.bak` and `file2.pl.bak` will be deleted if there are no errors.
+
+ perltidy -gnu somefile.pl
+
+Execute perltidy on file `somefile.pl` with a style which approximates the
+GNU Coding Standards for C programs. The output will be `somefile.pl.tdy`.
+
+ perltidy -i=3 somefile.pl
+
+Execute perltidy on file `somefile.pl`, with 3 columns for each level of
+indentation (**-i=3**) 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 `somefile.pl.tdy`.
+
+ perltidy -i=3 -et=8 somefile.pl
+
+Same as the previous example, except that leading whitespace will
+be entabbed with one tab character per 8 spaces.
+
+ perltidy -ce -l=72 somefile.pl
+
+Execute perltidy on file `somefile.pl` with all defaults except use "cuddled
+elses" (**-ce**) and a maximum line length of 72 columns (**-l=72**) instead of
+the default 80 columns.
+
+ perltidy -g somefile.pl
+
+Execute perltidy on file `somefile.pl` and save a log file `somefile.pl.LOG`
+which shows the nesting of braces, parentheses, and square brackets at
+the start of every line.
+
+ perltidy -html somefile.pl
+
+This will produce a file `somefile.pl.html` containing the script with
+html markup. The output file will contain an embedded style sheet in
+the <HEAD> section which may be edited to change the appearance.
+
+ perltidy -html -css=mystyle.css somefile.pl
+
+This will produce a file `somefile.pl.html` containing the script with
+html markup. This output file will contain a link to a separate style
+sheet file `mystyle.css`. If the file `mystyle.css` does not exist,
+it will be created. If it exists, it will not be overwritten.
+
+ perltidy -html -pre somefile.pl
+
+Write an html snippet with only the PRE section to `somefile.pl.html`.
+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.
+
+ perltidy -html -ss >mystyle.css
+
+Write a style sheet to `mystyle.css` and exit.
+
+ perltidy -html -frm mymodule.pm
+
+Write html with a frame holding a table of contents and the source code. The
+output files will be `mymodule.pm.html` (the frame), `mymodule.pm.toc.html`
+(the table of contents), and `mymodule.pm.src.html` (the source code).
+
+# OPTIONS - OVERVIEW
+
+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.
+
+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.
+
+Most parameters which serve as on/off flags can be negated with a
+leading "n" (for the short name) or a leading "no" or "no-" (for the
+long name). For example, the flag to outdent long quotes is **-olq**
+or **--outdent-long-quotes**. The flag to skip this is **-nolq**
+or **--nooutdent-long-quotes** or **--no-outdent-long-quotes**.
+
+Options may not be bundled together. In other words, options **-q** and
+**-g** may NOT be entered as **-qg**.
+
+Option names may be terminated early as long as they are uniquely identified.
+For example, instead of **--dump-token-types**, it would be sufficient to enter
+**--dump-tok**, or even **--dump-t**, to uniquely identify this command.
+
+## I/O control
+
+The following parameters concern the files which are read and written.
+
+- **-h**, **--help**
+
+ Show summary of usage and exit.
+
+- **-o**=filename, **--outfile**=filename
+
+ 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, the output will go to `filename.tdy`.
+
+- **-st**, **--standard-output**
+
+ 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, **-st**, is required to
+ request outputting to the standard output. For example,
+
+ perltidy somefile.pl -st >somefile.new.pl
+
+ This option may only be used if there is just a single input file.
+ The default is **-nst** or **--nostandard-output**.
+
+- **-se**, **--standard-error-output**
+
+ If perltidy detects an error when processing file `somefile.pl`, its
+ default behavior is to write error messages to file `somefile.pl.ERR`.
+ Use **-se** to cause all error messages to be sent to the standard error
+ output stream instead. This directive may be negated with **-nse**.
+ Thus, you may place **-se** in a `.perltidyrc` and override it when
+ desired with **-nse** on the command line.
+
+- **-oext**=ext, **--output-file-extension**=ext
+
+ Change the extension of the output file to be `ext` instead of the
+ default `tdy` (or `html` in case the -**-html** option is used).
+ See ["Specifying File Extensions"](#specifying-file-extensions).
+
+- **-opath**=path, **--output-path**=path
+
+ 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 `path` instead.
+
+ The path should end in a valid path separator character, but perltidy will try
+ to add one if it is missing.
+
+ For example
+
+ perltidy somefile.pl -opath=/tmp/
+
+ will produce `/tmp/somefile.pl.tdy`. Otherwise, `somefile.pl.tdy` will
+ appear in whatever directory contains `somefile.pl`.
+
+ If the path contains spaces, it should be placed in quotes.
+
+ This parameter will be ignored if output is being directed to standard output,
+ or if it is being specified explicitly with the **-o=s** parameter.
+
+- **-b**, **--backup-and-modify-in-place**
+
+ Modify the input file or files in-place and save the original with the
+ extension `.bak`. Any existing `.bak` file will be deleted. See next
+ item for changing the default backup extension, and for eliminating the
+ backup file altogether.
+
+ A **-b** flag will be ignored if input is from standard input or goes to
+ standard output, or if the **-html** flag is set.
+
+ In particular, if you want to use both the **-b** flag and the **-pbp**
+ (--perl-best-practices) flag, then you must put a **-nst** flag after the
+ **-pbp** flag because it contains a **-st** flag as one of its components,
+ which means that output will go to the standard output stream.
+
+- **-bext**=ext, **--backup-file-extension**=ext
+
+ This parameter serves two purposes: (1) to change the extension of the backup
+ file to be something other than the default `.bak`, and (2) to indicate
+ that no backup file should be saved.
+
+ To change the default extension to something other than `.bak` see
+ ["Specifying File Extensions"](#specifying-file-extensions).
+
+ 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.
+
+ To indicate that the backup should be deleted include one forward slash,
+ **/**, 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).
+
+ Here are some examples:
+
+ Parameter Extension Backup File Treatment
+ <-bext=bak> F<.bak> Keep (same as the default behavior)
+ <-bext='/'> F<.bak> Delete if no errors
+ <-bext='/backup'> F<.backup> Delete if no errors
+ <-bext='original/'> F<.original> Delete if no errors
+
+- **-w**, **--warning-output**
+
+ Setting **-w** 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, **-nw** or
+ **--nowarning-output**, is not to include these warnings.
+
+- **-q**, **--quiet**
+
+ Deactivate error messages and syntax checking (for running under
+ an editor).
+
+ 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
+
+ :n1,n2!perltidy -q
+
+ where `n1,n2` represents the selected text. Without the **-q** flag,
+ any error message may mess up your screen, so be prepared to use your
+ "undo" key.
+
+- **-log**, **--logfile**
+
+ Save the `.LOG` file, which has many useful diagnostics. Perltidy always
+ creates a `.LOG` file, but by default it is deleted unless a program bug is
+ suspected. Setting the **-log** flag forces the log file to be saved.
+
+- **-g=n**, **--logfile-gap=n**
+
+ 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 `n` is
+ optional. If you set the flag **-g** without the value of `n`, 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.
+
+ Setting **-g** also causes the logfile to be saved, so it is not necessary to
+ also include **-log**.
+
+ If no **-g** 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.
+
+ Setting a negative value of `n` is the same as not setting **-g** at all.
+
+- **-npro** **--noprofile**
+
+ Ignore any `.perltidyrc` command file. Normally, perltidy looks first in
+ your current directory for a `.perltidyrc` 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 `.perltidyrc` file is found, it looks for one
+ in your home directory.
+
+ If you set the **-npro** flag, perltidy will not look for this file.
+
+- **-pro=filename** or **--profile=filename**
+
+ 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
+ '=' sign. For example, the line
+
+ perltidy -pro=testcfg
+
+ would cause file `testcfg` to be used instead of the
+ default `.perltidyrc`.
+
+ A pathname begins with three dots, e.g. ".../.perltidyrc", 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.
+
+- **-opt**, **--show-options**
+
+ Write a list of all options used to the `.LOG` file.
+ Please see **--dump-options** for a simpler way to do this.
+
+- **-f**, **--force-read-binary**
+
+ 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.
+
+# FORMATTING OPTIONS
+
+## Basic Options
+
+- **--notidy**
+
+ 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 `.perltidyrc` files to avoid unwanted code tidying. See also
+ ["Skipping Selected Sections of Code"](#skipping-selected-sections-of-code) for a way to avoid tidying specific
+ sections of code.
+
+- **-i=n**, **--indent-columns=n**
+
+ Use n columns per indentation level (default n=4).
+
+- **-l=n**, **--maximum-line-length=n**
+
+ 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 **-l=0** is equivalent to setting **-l=(a large number)**.
+
+- **-vmll**, **--variable-maximum-line-length**
+
+ 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 **-vmll** flag, which
+ basically tells perltidy to ignore leading whitespace when measuring the line
+ length.
+
+ To be precise, when the **-vmll** parameter is set, the maximum line length of a
+ line of code will be M+L\*I, where
+
+ M is the value of --maximum-line-length=M (-l=M), default 80,
+ I is the value of --indent-columns=I (-i=I), default 4,
+ L is the indentation level of the line of code
+
+ 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.
+
+ The default is not to do this (**-nvmll**).
+
+- **-wc=n**, **--whitespace-cycle=n**
+
+ This flag also addresses problems with very deeply nested code and data
+ structures. When the nesting depth exceeds the value **n** 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.
+
+ For example if one level of indentation equals 4 spaces (**-i=4**, the default),
+ and one uses **-wc=15**, 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.
+
+ The combination of **-vmll** and **-wc=n** provides a solution to the problem of
+ displaying arbitrarily deep data structures and code in a finite window,
+ although **-wc=n** may of course be used without **-vmll**.
+
+ The default is not to use this, which can also be indicated using **-wc=0**.
+
+- tabs
+
+ 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.
+
+ 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 **-fws**). If you have any tabs in your comments, quotes, or
+ here-documents, they will remain.
+
+ - **-et=n**, **--entab-leading-whitespace**
+
+ This flag causes each **n** initial space characters to be replaced by
+ one tab character. Note that the integer **n** is completely independent
+ of the integer specified for indentation parameter, **-i=n**.
+
+ - **-t**, **--tabs**
+
+ 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 **-lp**
+ option.
+
+ - **-dt=n**, **--default-tabsize=n**
+
+ 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 **n**
+ corresponding to each leading tab of the input stream may be specified with
+ **-dt=n**. The default is **n=8**.
+
+ 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).
+
+- **-syn**, **--check-syntax**
+
+ This flag is now ignored for safety, but the following documentation
+ has been retained for reference.
+
+ This flag causes perltidy to run `perl -c -T` to check syntax of input
+ and output. (To change the flags passed to perl, see the next
+ item, **-pscf**). The results are written to the `.LOG` 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 "second
+ opinion".
+
+ If perl reports errors in the input file, they will not be reported in
+ the error output unless the **--warning-output** flag is given.
+
+ The default is **NOT** 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.
+
+- **-pscf=s**, **-perl-syntax-check-flags=s**
+
+ When perl is invoked to check syntax, the normal flags are `-c -T`. In
+ addition, if the **-x** flag is given to perltidy, then perl will also be
+ passed a **-x** flag. It should not normally be necessary to change
+ these flags, but it can be done with the **-pscf=s** flag. For example,
+ if the taint flag, `-T`, is not wanted, the flag could be set to be just
+ **-pscf=-c**.
+
+ Perltidy will pass your string to perl with the exception that it will
+ add a **-c** and **-x** if appropriate. The `.LOG` file will show
+ exactly what flags were passed to perl.
+
+- **-xs**, **--extended-syntax**
+
+ 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.
+
+ For example, without this flag a structure such as the following would generate
+ a syntax error and the braces would not be balanced:
+
+ method deposit( Num $amount) {
+ $self->balance( $self->balance + $amount );
+ }
+
+ This flag is enabled by default but it can be deactivated with **-nxs**.
+ Probably the only reason to deactivate this flag is to generate more diagnostic
+ messages when debugging a script.
+
+- **-io**, **--indent-only**
+
+ 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).
+
+ Setting this flag is equivalent to setting **--freeze-newlines** and
+ **--freeze-whitespace**.
+
+ If you also want to keep your existing blank lines exactly
+ as they are, you can add **--freeze-blank-lines**.
+
+ 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 **-noll** or
+ **-l=0**.
+
+ 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.
+
+- **-enc=s**, **--character-encoding=s**
+
+ where **s**=**none** or **utf8**. This flag tells perltidy the character encoding
+ of both the input and output character streams. The value **utf8** causes the
+ stream to be read and written as UTF-8. The value **none** 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 `'use utf8'`
+ 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.
+
+ The default is **none**.
+
+ The abbreviations **-utf8** or **-UTF8** are equivalent to **-enc=utf8**.
+ So to process a file named **file.pl** which is encoded in UTF-8 you can use:
+
+ perltidy -utf8 file.pl
+
+- **-ole=s**, **--output-line-ending=s**
+
+ where s=`win`, `dos`, `unix`, or `mac`. 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 `win` and `dos` flags have an identical result.
+
+- **-ple**, **--preserve-line-endings**
+
+ This flag tells perltidy to write its output files with the same line
+ endings as the input file, if possible. It should work for
+ **dos**, **unix**, and **mac** 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.
+
+- **-it=n**, **--iterations=n**
+
+ This flag causes perltidy to do **n** 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 **n=1** should be satisfactory. However **n=2**
+ 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
+ **n** 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.
+
+ This flag has no effect when perltidy is used to generate html.
+
+- **-conv**, **--converge**
+
+ This flag is equivalent to **-it=4** 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 **-nconv** (no convergence check). Using
+ **-conv** will approximately double run time since normally one extra iteration
+ is required to verify convergence.
+
+## Code Indentation Control
+
+- **-ci=n**, **--continuation-indentation=n**
+
+ Continuation indentation is extra indentation spaces applied when
+ a long line is broken. The default is n=2, illustrated here:
+
+ my $level = # -ci=2
+ ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
+
+ The same example, with n=0, is a little harder to read:
+
+ my $level = # -ci=0
+ ( $max_index_to_go >= 0 ) ? $levels_to_go[0] : $last_output_level;
+
+ The value given to **-ci** is also used by some commands when a small
+ space is required. Examples are commands for outdenting labels,
+ **-ola**, and control keywords, **-okw**.
+
+ When default values are not used, it is suggested that the value **n**
+ given with **-ci=n** be no more than about one-half of the number of
+ spaces assigned to a full indentation level on the **-i=n** command.
+
+- **-sil=n** **--starting-indentation-level=n**
+
+ 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.
+
+ 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'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.
+
+ If the default method does not work correctly, or you want to change the
+ starting level, use **-sil=n**, to force the starting level to be n.
+
+- List indentation using **-lp**, **--line-up-parentheses**
+
+ By default, perltidy indents lists with 4 spaces, or whatever value
+ is specified with **-i=n**. Here is a small list formatted in this way:
+
+ # perltidy (default)
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ Use the **-lp** 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:
+
+ # perltidy -lp
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ If the available line length (see **-l=n** ) does not permit this much
+ space, perltidy will use less. For alternate placement of the
+ closing paren, see the next section.
+
+ This option has no effect on code BLOCKS, such as if/then/else blocks,
+ which always use whatever is specified with **-i=n**. 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.
+
+ Note: The **-lp** option may not be used together with the **-t** tabs option.
+ It may, however, be used with the **-et=n** tab method.
+
+ In addition, any parameter which significantly restricts the ability of
+ perltidy to choose newlines will conflict with **-lp** and will cause
+ **-lp** to be deactivated. These include **-io**, **-fnl**, **-nanl**, and
+ **-ndnl**. The reason is that the **-lp** indentation style can require
+ the careful coordination of an arbitrary number of break points in
+ hierarchical lists, and these flags may prevent that.
+
+- **-cti=n**, **--closing-token-indentation**
+
+ The **-cti=n** flag controls the indentation of a line beginning with
+ a `)`, `]`, or a non-block `}`. Such a line receives:
+
+ -cti = 0 no extra indentation (default)
+ -cti = 1 extra indentation such that the closing token
+ aligns with its opening token.
+ -cti = 2 one extra indentation level if the line looks like:
+ ); or ]; or };
+ -cti = 3 one extra indentation level always
+
+ The flags **-cti=1** and **-cti=2** work well with the **-lp** flag (previous
+ section).
+
+ # perltidy -lp -cti=1
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ # perltidy -lp -cti=2
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+ 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
+ **cti=1** is constrained to be no more than one indentation level.
+
+ If desired, this control can be applied independently to each of the
+ closing container token types. In fact, **-cti=n** is merely an
+ abbreviation for **-cpi=n -csbi=n -cbi=n**, where:
+ **-cpi** or **--closing-paren-indentation** controls **)**'s,
+ **-csbi** or **--closing-square-bracket-indentation** controls **\]**'s,
+ **-cbi** or **--closing-brace-indentation** controls non-block **}**'s.
+
+- **-icp**, **--indent-closing-paren**
+
+ The **-icp** flag is equivalent to
+ **-cti=2**, described in the previous section. The **-nicp** flag is
+ equivalent **-cti=0**. They are included for backwards compatibility.
+
+- **-icb**, **--indent-closing-brace**
+
+ The **-icb** option gives one extra level of indentation to a brace which
+ terminates a code block . For example,
+
+ if ($task) {
+ yyy();
+ } # -icb
+ else {
+ zzz();
+ }
+
+ The default is not to do this, indicated by **-nicb**.
+
+- **-olq**, **--outdent-long-quotes**
+
+ When **-olq** is set, lines which is a quoted string longer than the
+ value **maximum-line-length** will have their indentation removed to make
+ them more readable. This is the default. To prevent such out-denting,
+ use **-nolq** or **--nooutdent-long-lines**.
+
+- **-oll**, **--outdent-long-lines**
+
+ This command is equivalent to **--outdent-long-quotes** and
+ **--outdent-long-comments**, and it is included for compatibility with previous
+ versions of perltidy. The negation of this also works, **-noll** or
+ **--nooutdent-long-lines**, and is equivalent to setting **-nolq** and **-nolc**.
+
+- Outdenting Labels: **-ola**, **--outdent-labels**
+
+ This command will cause labels to be outdented by 2 spaces (or whatever **-ci**
+ has been set to), if possible. This is the default. For example:
+
+ my $i;
+ LOOP: while ( $i = <FOTOS> ) {
+ chomp($i);
+ next unless $i;
+ fixit($i);
+ }
+
+ Use **-nola** to not outdent labels.
+
+- Outdenting Keywords
+ - **-okw**, **--outdent-keywords**
+
+ The command **-okw** will cause certain leading control keywords to
+ be outdented by 2 spaces (or whatever **-ci** has been set to), if
+ possible. By default, these keywords are `redo`, `next`, `last`,
+ `goto`, and `return`. The intention is to make these control keywords
+ easier to see. To change this list of keywords being outdented, see
+ the next section.
+
+ For example, using `perltidy -okw` on the previous example gives:
+
+ my $i;
+ LOOP: while ( $i = <FOTOS> ) {
+ chomp($i);
+ next unless $i;
+ fixit($i);
+ }
+
+ The default is not to do this.
+
+ - Specifying Outdented Keywords: **-okwl=string**, **--outdent-keyword-list=string**
+
+ This command can be used to change the keywords which are outdented with
+ the **-okw** command. The parameter **string** 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 **-okw**
+ command is still required.
+
+ For example, the commands `-okwl="next last redo goto" -okw` will cause
+ those four keywords to be outdented. It is probably simplest to place
+ any **-okwl** command in a `.perltidyrc` file.
+
+## Whitespace Control
+
+Whitespace refers to the blank space between variables, operators,
+and other code tokens.
+
+- **-fws**, **--freeze-whitespace**
+
+ 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.
+
+- Tightness of curly braces, parentheses, and square brackets.
+
+ Here the term "tightness" 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 `(` then there
+ will be a space before the corresponding `)`.
+
+ The **-pt=n** or **--paren-tightness=n** parameter controls the space within
+ parens. The example below shows the effect of the three possible
+ values, 0, 1, and 2:
+
+ if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
+ if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
+ if ((my $len_tab = length($tabstr)) > 0) { # -pt=2
+
+ When n is 0, there is always a space to the right of a '(' and to the left
+ of a ')'. 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.
+
+ Likewise, the parameter **-sbt=n** or **--square-bracket-tightness=n**
+ controls the space within square brackets, as illustrated below.
+
+ $width = $col[ $j + $k ] - $col[ $j ]; # -sbt=0
+ $width = $col[ $j + $k ] - $col[$j]; # -sbt=1 (default)
+ $width = $col[$j + $k] - $col[$j]; # -sbt=2
+
+ Curly braces which do not contain code blocks are controlled by
+ the parameter **-bt=n** or **--brace-tightness=n**.
+
+ $obj->{ $parsed_sql->{ 'table' }[0] }; # -bt=0
+ $obj->{ $parsed_sql->{'table'}[0] }; # -bt=1 (default)
+ $obj->{$parsed_sql->{'table'}[0]}; # -bt=2
+
+ And finally, curly braces which contain blocks of code are controlled by the
+ parameter **-bbt=n** or **--block-brace-tightness=n** as illustrated in the
+ example below.
+
+ %bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.'; # -bbt=0 (default)
+ %bf = map { $_ => -M $_ } grep {/\.deb$/} dirents '.'; # -bbt=1
+ %bf = map {$_ => -M $_} grep {/\.deb$/} dirents '.'; # -bbt=2
+
+ To simplify input in the case that all of the tightness flags have the same
+ value <n>, the parameter <-act=n> or **--all-containers-tightness=n** is an
+ abbreviation for the combination <-pt=n -sbt=n -bt=n -bbt=n>.
+
+- **-tso**, **--tight-secret-operators**
+
+ The flag **-tso** causes certain perl token sequences (secret operators)
+ which might be considered to be a single operator to be formatted "tightly"
+ (without spaces). The operators currently modified by this flag are:
+
+ 0+ +0 ()x!! ~~<> ,=> =( )=
+
+ For example the sequence **0 +**, which converts a string to a number,
+ would be formatted without a space: **0+** when the **-tso** flag is set. This
+ flag is off by default.
+
+- **-sts**, **--space-terminal-semicolon**
+
+ Some programmers prefer a space before all terminal semicolons. The
+ default is for no such space, and is indicated with **-nsts** or
+ **--nospace-terminal-semicolon**.
+
+ $i = 1 ; # -sts
+ $i = 1; # -nsts (default)
+
+- **-sfs**, **--space-for-semicolon**
+
+ Semicolons within **for** 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
+ **-nsfs** or **--nospace-for-semicolon** to deactivate it.
+
+ for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) { # -sfs (default)
+ for ( @a = @$ap, $u = shift @a; @a; $u = $v ) { # -nsfs
+
+- **-asc**, **--add-semicolons**
+
+ Setting **-asc** 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 **-nasc** or **--noadd-semicolons**.
+
+- **-dsm**, **--delete-semicolons**
+
+ Setting **-dsm** allows perltidy to delete extra semicolons which are
+ simply empty statements. This is the default, and may be deactivated
+ with **-ndsm** or **--nodelete-semicolons**. (Such semicolons are not
+ deleted, however, if they would promote a side comment to a block
+ comment).
+
+- **-aws**, **--add-whitespace**
+
+ 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
+ **-naws**. (Use **-fws** to leave whitespace completely unchanged).
+
+- **-dws**, **--delete-old-whitespace**
+
+ 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 **-ndws** or
+ **--nodelete-old-whitespace**.
+
+- Detailed whitespace controls around tokens
+
+ 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:
+
+ **-wls=s** or **--want-left-space=s**,
+
+ **-nwls=s** or **--nowant-left-space=s**,
+
+ **-wrs=s** or **--want-right-space=s**,
+
+ **-nwrs=s** or **--nowant-right-space=s**.
+
+ These parameters are each followed by a quoted string, **s**, 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.
+
+ To illustrate how these are used, suppose it is desired that there be no
+ space on either side of the token types **= + - / \***. The following two
+ parameters would specify this desire:
+
+ -nwls="= + - / *" -nwrs="= + - / *"
+
+ (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:
+
+ $root = -$b + sqrt( $b * $b - 4. * $a * $c ) / ( 2. * $a );
+
+ becomes this:
+
+ $root=-$b+sqrt( $b*$b-4.*$a*$c )/( 2.*$a );
+
+ 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't. In this case, the token not wanting
+ a space takes priority.
+
+ 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
+ **--dump-token-types**. Also try the **-D** flag on a short snippet of code
+ and look at the .DEBUG file to see the tokenization.
+
+ **WARNING** Be sure to put these tokens in quotes to avoid having them
+ misinterpreted by your command shell.
+
+- Space between specific keywords and opening paren
+
+ When an opening paren follows a Perl keyword, no space is introduced after the
+ keyword, unless it is (by default) one of these:
+
+ my local our and or eq ne if else elsif until unless
+ while for foreach return switch case given when
+
+ These defaults can be modified with two commands:
+
+ **-sak=s** or **--space-after-keyword=s** adds keywords.
+
+ **-nsak=s** or **--nospace-after-keyword=s** removes keywords.
+
+ where **s** is a list of keywords (in quotes if necessary). For example,
+
+ my ( $a, $b, $c ) = @_; # default
+ my( $a, $b, $c ) = @_; # -nsak="my local our"
+
+ The abbreviation **-nsak='\*'** is equivalent to including all of the
+ keywords in the above list.
+
+ When both **-nsak=s** and **-sak=s** commands are included, the **-nsak=s**
+ command is executed first. For example, to have space after only the
+ keywords (my, local, our) you could use **-nsak="\*" -sak="my local our"**.
+
+ To put a space after all keywords, see the next item.
+
+- Space between all keywords and opening parens
+
+ 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:
+
+ **-skp** or **--space-keyword-paren**
+
+ You will probably also want to use the flag **-sfp** (next item) too.
+
+- Space between all function names and opening parens
+
+ When an opening paren follows a function the default is not to introduce
+ a space. To cause a space to be introduced use:
+
+ **-sfp** or **--space-function-paren**
+
+ myfunc( $a, $b, $c ); # default
+ myfunc ( $a, $b, $c ); # -sfp
+
+ You will probably also want to use the flag **-skp** (previous item) too.
+
+- Trimming whitespace around `qw` quotes
+
+ **-tqw** or **--trim-qw** provide the default behavior of trimming
+ spaces around multi-line `qw` quotes and indenting them appropriately.
+
+ **-ntqw** or **--notrim-qw** cause leading and trailing whitespace around
+ multi-line `qw` 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 `qw` quotes changes the syntax tree.
+
+- **-sbq=n** or **--space-backslash-quote=n**
+
+ Lines like
+
+ $str1=\"string1";
+ $str2=\'string2';
+
+ can confuse syntax highlighters unless a space is included between the backslash and the single or double quotation mark.
+
+ This can be controlled with the value of **n** as follows:
+
+ -sbq=0 means no space between the backslash and quote
+ -sbq=1 means follow the example of the source code
+ -sbq=2 means always put a space between the backslash and quote
+
+ The default is **-sbq=1**, meaning that a space will be used 0if there is one in the source code.
+
+- Trimming trailing whitespace from lines of POD
+
+ **-trp** or **--trim-pod** will remove trailing whitespace from lines of POD.
+ The default is not to do this.
+
+## Comment Controls
+
+Perltidy has a number of ways to control the appearance of both block comments
+and side comments. The term **block comment** here refers to a full-line
+comment, whereas **side comment** will refer to a comment which appears on a
+line to the right of some code.
+
+- **-ibc**, **--indent-block-comments**
+
+ 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 **-nibc** to keep block comments left-justified. Here is an
+ example:
+
+ # this comment is indented (-ibc, default)
+ if ($task) { yyy(); }
+
+ The alternative is **-nibc**:
+
+ # this comment is not indented (-nibc)
+ if ($task) { yyy(); }
+
+ See also the next item, **-isbc**, as well as **-sbc**, for other ways to
+ have some indented and some outdented block comments.
+
+- **-isbc**, **--indent-spaced-block-comments**
+
+ If there is no leading space on the line, then the comment will not be
+ indented, and otherwise it may be.
+
+ If both **-ibc** and **-isbc** are set, then **-isbc** takes priority.
+
+- **-olc**, **--outdent-long-comments**
+
+ When **-olc** is set, lines which are full-line (block) comments longer
+ than the value **maximum-line-length** will have their indentation
+ removed. This is the default; use **-nolc** to prevent outdenting.
+
+- **-msc=n**, **--minimum-space-to-comment=n**
+
+ 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.
+
+- **-fpsc=n**, **--fixed-position-side-comment=n**
+
+ This parameter tells perltidy to line up side comments in column number **n**
+ whenever possible. The default, n=0, will not do this.
+
+- **-iscl**, **--ignore-side-comment-lengths**
+
+ This parameter causes perltidy to ignore the length of side comments when
+ setting line breaks. The default, **-niscl**, is to include the length of
+ side comments when breaking lines to stay within the length prescribed
+ by the **-l=n** maximum line length parameter. For example, the following
+ long single line would remain intact with -l=80 and -iscl:
+
+ perltidy -l=80 -iscl
+ $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well
+
+ whereas without the -iscl flag the line will be broken:
+
+ perltidy -l=80
+ $vmsfile =~ s/;[\d\-]*$//
+ ; # Clip off version number; we can use a newer version as well
+
+
+- **-hsc**, **--hanging-side-comments**
+
+ By default, perltidy tries to identify and align "hanging side
+ comments", which are something like this:
+
+ my $IGNORE = 0; # This is a side comment
+ # This is a hanging side comment
+ # And so is this
+
+ 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 **-nhsc** or **--nohanging-side-comments**.
+ If block comments are preceded by a blank line, or have no leading
+ whitespace, they will not be mistaken as hanging side comments.
+
+- Closing Side Comments
+
+ 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
+ **-csc** (or **--closing-side-comments**) adds or updates closing side
+ comments. For example, here is a small code snippet
+
+ sub message {
+ if ( !defined( $_[0] ) ) {
+ print("Hello, World\n");
+ }
+ else {
+ print( $_[0], "\n" );
+ }
+ }
+
+ And here is the result of processing with `perltidy -csc`:
+
+ sub message {
+ if ( !defined( $_[0] ) ) {
+ print("Hello, World\n");
+ }
+ else {
+ print( $_[0], "\n" );
+ }
+ } ## end sub message
+
+ A closing side comment was added for `sub message` in this case, but not
+ for the `if` and `else` blocks, because they were below the 6 line
+ cutoff limit for adding closing side comments. This limit may be
+ changed with the **-csci** command, described below.
+
+ The command **-dcsc** (or **--delete-closing-side-comments**) reverses this
+ process and removes these comments.
+
+ Several commands are available to modify the behavior of these two basic
+ commands, **-csc** and **-dcsc**:
+
+ - **-csci=n**, or **--closing-side-comment-interval=n**
+
+ where `n` 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
+ `n=6`. To illustrate:
+
+ # perltidy -csci=2 -csc
+ sub message {
+ if ( !defined( $_[0] ) ) {
+ print("Hello, World\n");
+ } ## end if ( !defined( $_[0] ))
+ else {
+ print( $_[0], "\n" );
+ } ## end else [ if ( !defined( $_[0] ))
+ } ## end sub message
+
+ Now the `if` and `else` blocks are commented. However, now this has
+ become very cluttered.
+
+ - **-cscp=string**, or **--closing-side-comment-prefix=string**
+
+ where string is the prefix used before the name of the block type. The
+ default prefix, shown above, is `## end`. 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.
+
+ - **-cscl=string**, or **--closing-side-comment-list**
+
+ where `string` 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 `if`, `sub`, and so on) will be tagged. The **-cscl**
+ command changes the default list to be any selected block types; see
+ ["Specifying Block Types"](#specifying-block-types).
+ For example, the following command
+ requests that only `sub`'s, labels, `BEGIN`, and `END` blocks be
+ affected by any **-csc** or **-dcsc** operation:
+
+ -cscl="sub : BEGIN END"
+
+ - **-csct=n**, or **--closing-side-comment-maximum-text=n**
+
+ The text appended to certain block types, such as an `if` block, is
+ whatever lies between the keyword introducing the block, such as `if`,
+ 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 `n=20`, meaning that no additional
+ tokens will be appended to this text after its length reaches 20
+ characters. Omitted text is indicated with `...`. (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 ` ( !defined( $_[0] )...`. The existing limit of
+ `n=20` caused this text to be truncated, as indicated by the `...`. See
+ the next flag for additional control of the abbreviated text.
+
+ - **-cscb**, or **--closing-side-comments-balanced**
+
+ 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:
+
+ perltidy -csc -ncscb
+ } ## end foreach my $foo (sort { $b cmp $a ...
+
+ However this causes a problem with editors which cannot recognize
+ comments or are not configured to do so because they cannot "bounce" around in
+ the text correctly. The **-cscb** flag has been added to
+ help them by appending appropriate balancing structure:
+
+ perltidy -csc -cscb
+ } ## end foreach my $foo (sort { $b cmp $a ... })
+
+ The default is **-cscb**.
+
+ - **-csce=n**, or **--closing-side-comment-else-flag=n**
+
+ The default, **n=0**, places the text of the opening `if` statement after any
+ terminal `else`.
+
+ If **n=2** is used, then each `elsif` is also given the text of the opening
+ `if` statement. Also, an `else` will include the text of a preceding
+ `elsif` statement. Note that this may result some long closing
+ side comments.
+
+ If **n=1** is used, the results will be the same as **n=2** whenever the
+ resulting line length is less than the maximum allowed.
+
+ - **-cscb**, or **--closing-side-comments-balanced**
+
+ 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 **-cscb** flag is negated:
+
+ perltidy -csc -ncscb
+ } ## end foreach my $foo (sort { $b cmp $a ...
+
+ This causes a problem with older editors which do not recognize comments
+ because they cannot "bounce" around in the text correctly. The **-cscb**
+ flag tries to help them by appending appropriate terminal balancing structures:
+
+ perltidy -csc -cscb
+ } ## end foreach my $foo (sort { $b cmp $a ... })
+
+ The default is **-cscb**.
+
+ - **-cscw**, or **--closing-side-comment-warnings**
+
+ 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.
+
+ 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 **-csc**.
+
+ **Important Notes on Closing Side Comments:**
+
+ - Closing side comments are only placed on lines terminated with a closing
+ brace. Certain closing styles, such as the use of cuddled elses
+ (**-ce**), preclude the generation of some closing side comments.
+ - Please note that adding or deleting of closing side comments takes
+ place only through the commands **-csc** or **-dcsc**. The other commands,
+ if used, merely modify the behavior of these two commands.
+ - It is recommended that the **-cscw** flag be used along with **-csc** 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.
+ - Once you use **-csc**, 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.
+ - 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 **-csc**. For
+ example, you could simply change `## end` to be `## End`, since the test is
+ case sensitive. You may also want to use the **-ssc** flag to keep these
+ modified closing side comments spaced the same as actual closing side comments.
+ - 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 **-dcsc**.
+
+- Static Block Comments
+
+ Static block comments are block comments with a special leading pattern,
+ `##` 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.
+
+ - **-sbc**, **--static-block-comments**
+
+ When **-sbc** is used, a block comment with a special leading pattern, `##` by
+ default, will be treated specially.
+
+ Comments so identified are treated as follows:
+
+ - If there is no leading space on the line, then the comment will not
+ be indented, and otherwise it may be,
+ - no new blank line will be
+ inserted before such a comment, and
+ - such a comment will never become
+ a hanging side comment.
+
+ For example, assuming `@month_of_year` is
+ left-adjusted:
+
+ @month_of_year = ( # -sbc (default)
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+ ## 'Dec', 'Nov'
+ 'Nov', 'Dec');
+
+ Without this convention, the above code would become
+
+ @month_of_year = ( # -nsbc
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
+
+ ## 'Dec', 'Nov'
+ 'Nov', 'Dec'
+ );
+
+ which is not as clear.
+ The default is to use **-sbc**. This may be deactivated with **-nsbc**.
+
+ - **-sbcp=string**, **--static-block-comment-prefix=string**
+
+ This parameter defines the prefix used to identify static block comments
+ when the **-sbc** parameter is set. The default prefix is `##`,
+ corresponding to `-sbcp=##`. The prefix is actually part of a perl
+ pattern used to match lines and it must either begin with `#` or `^#`.
+ 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 `-sbcp=#`.
+ To identify all left-adjusted comments as static block comments, use `-sbcp='^#'`.
+
+ Please note that **-sbcp** merely defines the pattern used to identify static
+ block comments; it will not be used unless the switch **-sbc** 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.
+
+ A pattern which can be useful is:
+
+ -sbcp=^#{2,}[^\s#]
+
+ 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 '#'
+ 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 '#'.
+
+ - **-osbc**, **--outdent-static-block-comments**
+
+ The command **-osbc** will cause static block comments to be outdented by 2
+ spaces (or whatever **-ci=n** has been set to), if possible.
+
+- Static Side Comments
+
+ 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.
+
+ - **-ssc**, **--static-side-comments**
+
+ When **-ssc** is used, a side comment with a static leading pattern, which is
+ `##` by default, will be spaced only a single space from previous
+ character, and it will not be vertically aligned with other side comments.
+
+ The default is **-nssc**.
+
+ - **-sscp=string**, **--static-side-comment-prefix=string**
+
+ This parameter defines the prefix used to identify static side comments
+ when the **-ssc** parameter is set. The default prefix is `##`,
+ corresponding to `-sscp=##`.
+
+ Please note that **-sscp** merely defines the pattern used to identify
+ static side comments; it will not be used unless the switch **-ssc** 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.
+
+## Skipping Selected Sections of Code
+
+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 **--noformat-skipping** or **-nfs** 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.
+
+- **-fs**, **--format-skipping**
+
+ 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 #<<<
+ and the default ending marker is #>>> 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
+
+ #<<< do not let perltidy touch this
+ my @list = (1,
+ 1, 1,
+ 1, 2, 1,
+ 1, 3, 3, 1,
+ 1, 4, 6, 4, 1,);
+ #>>>
+
+ 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
+ `.LOG` file. Use **-nfs** to disable this feature.
+
+- **-fsb=string**, **--format-skipping-begin=string**
+
+ The **-fsb=string** parameter may be used to change the beginning marker for
+ format skipping. The default is equivalent to -fsb='#<<<'. 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 '\\s', so you must also include backslashes
+ for characters to be taken literally rather than as patterns.
+
+ Some examples show how example strings become patterns:
+
+ -fsb='#\{\{\{' becomes /^#\{\{\{\s/ which matches #{{{ but not #{{{{
+ -fsb='#\*\*' becomes /^#\*\*\s/ which matches #** but not #***
+ -fsb='#\*{2,}' becomes /^#\*{2,}\s/ which matches #** and #*****
+
+- **-fse=string**, **--format-skipping-end=string**
+
+ The **-fsb=string** is the corresponding parameter used to change the
+ ending marker for format skipping. The default is equivalent to
+ \-fse='#<<<'.
+
+## Line Break Control
+
+The parameters in this section control breaks after
+non-blank lines of code. Blank lines are controlled
+separately by parameters in the section ["Blank Line
+Control"](#blank-line-control).
+
+- **-fnl**, **--freeze-newlines**
+
+ If you do not want any changes to the line breaks within
+ lines of code in your script, set
+ **-fnl**, and they will remain fixed, and the rest of the commands in
+ this section and sections
+ ["Controlling List Formatting"](#controlling-list-formatting),
+ ["Retaining or Ignoring Existing Line Breaks"](#retaining-or-ignoring-existing-line-breaks).
+ You may want to use **-noll** with this.
+
+ Note: If you also want to keep your blank lines exactly
+ as they are, you can use the **-fbl** flag which is described
+ in the section ["Blank Line Control"](#blank-line-control).
+
+- **-ce**, **--cuddled-else**
+
+ Enable the "cuddled else" style, in which `else` and `elsif` 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
+ **-nce** or **--nocuddled-else**. Here is a comparison of the
+ alternatives:
+
+ # -ce
+ if ($task) {
+ yyy();
+ } else {
+ zzz();
+ }
+
+ # -nce (default)
+ if ($task) {
+ yyy();
+ }
+ else {
+ zzz();
+ }
+
+ In this example the keyword **else** 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 "cuddled" style are **elsif**, **continue**, **catch**, **finally**.
+
+ Other block types can be formatted by specifying their names on a
+ separate parameter **-cbl**, described in a later section.
+
+ 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 **-cbo=n** discussed below. The default
+ and recommended value of **-cbo=1** 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.
+
+ So for example, the **-ce** flag would not have any effect if the above snippet
+ is rewritten as
+
+ if ($task) { yyy() }
+ else { zzz() }
+
+ 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.
+
+ 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.
+
+- **-cb**, **--cuddled-blocks**
+
+ This flag is equivalent to **-ce**.
+
+- **-cbl**, **--cuddled-block-list**
+
+ The built-in default cuddled block types are **else, elsif, continue, catch, finally**.
+
+ Additional block types to which the **-cuddled-blocks** 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
+
+ -cbl="sort map grep"
+
+ or equivalently
+
+ -cbl=sort,map,grep
+
+ Note however that these particular block types are typically short so there might not be much
+ opportunity for the cuddled format style.
+
+ Using commas avoids the need to protect spaces with quotes.
+
+ As a diagnostic check, the flag **--dump-cuddled-block-list** or **-dcbl** can be
+ used to view the hash of values that are generated by this flag.
+
+ Finally, note that the **-cbl** flag by itself merely specifies which blocks are formatted
+ with the cuddled format. It has no effect unless this formatting style is activated with
+ **-ce**.
+
+- **-cblx**, **--cuddled-block-list-exclusive**
+
+ When cuddled else formatting is selected with **-ce**, setting this flag causes
+ perltidy to ignore its built-in defaults and rely exclusively on the block types
+ specified on the **-cbl** flag described in the previous section. For example,
+ to avoid using cuddled **catch** and **finally**, which among in the defaults, the
+ following set of parameters could be used:
+
+ perltidy -ce -cbl='else elsif continue' -cblx
+
+- **-cbo=n**, **--cuddled-break-option=n**
+
+ 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 "break" the block, meaning
+ to cause it to span multiple lines. This parameter controls that decision. The
+ options are:
+
+ cbo=0 Never force a short block to break.
+ cbo=1 If the first of a pair of blocks is broken in the input file,
+ then break the second [DEFAULT].
+ cbo=2 Break open all blocks for maximal cuddled formatting.
+
+ The default and recommended value is **cbo=1**. 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.
+
+ The option **cbo=0** can produce erratic cuddling if there are numerous one-line
+ blocks.
+
+ The option **cbo=2** produces maximal cuddling but will not allow any short blocks.
+
+- **-bl**, **--opening-brace-on-new-line**
+
+ Use the flag **-bl** to place the opening brace on a new line:
+
+ if ( $input_file eq '-' ) # -bl
+ {
+ important_function();
+ }
+
+ This flag applies to all structural blocks, including named sub's (unless
+ the **-sbl** flag is set -- see next item).
+
+ The default style, **-nbl**, places an opening brace on the same line as
+ the keyword introducing it. For example,
+
+ if ( $input_file eq '-' ) { # -nbl (default)
+
+- **-sbl**, **--opening-sub-brace-on-new-line**
+
+ The flag **-sbl** can be used to override the value of **-bl** for
+ the opening braces of named sub's. For example,
+
+ perltidy -sbl
+
+ produces this result:
+
+ sub message
+ {
+ if (!defined($_[0])) {
+ print("Hello, World\n");
+ }
+ else {
+ print($_[0], "\n");
+ }
+ }
+
+ This flag is negated with **-nsbl**. If **-sbl** is not specified,
+ the value of **-bl** is used.
+
+- **-asbl**, **--opening-anonymous-sub-brace-on-new-line**
+
+ The flag **-asbl** is like the **-sbl** flag except that it applies
+ to anonymous sub's instead of named subs. For example
+
+ perltidy -asbl
+
+ produces this result:
+
+ $a = sub
+ {
+ if ( !defined( $_[0] ) ) {
+ print("Hello, World\n");
+ }
+ else {
+ print( $_[0], "\n" );
+ }
+ };
+
+ This flag is negated with **-nasbl**, and the default is **-nasbl**.
+
+- **-bli**, **--brace-left-and-indent**
+
+ The flag **-bli** is the same as **-bl** but in addition it causes one
+ unit of continuation indentation ( see **-ci** ) to be placed before
+ an opening and closing block braces.
+
+ For example,
+
+ if ( $input_file eq '-' ) # -bli
+ {
+ important_function();
+ }
+
+ By default, this extra indentation occurs for blocks of type:
+ **if**, **elsif**, **else**, **unless**, **for**, **foreach**, **sub**,
+ **while**, **until**, and also with a preceding label. The next item
+ shows how to change this.
+
+- **-blil=s**, **--brace-left-and-indent-list=s**
+
+ Use this parameter to change the types of block braces for which the
+ **-bli** flag applies; see ["Specifying Block Types"](#specifying-block-types). For example,
+ **-blil='if elsif else'** would apply it to only `if/elsif/else` blocks.
+
+- **-bar**, **--opening-brace-always-on-right**
+
+ The default style, **-nbl** 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:
+
+ if ( $bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4 )
+ {
+ big_waste_of_time();
+ }
+
+ To force the opening brace to always be on the right, use the **-bar**
+ flag. In this case, the above example becomes
+
+ if ( $bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4 ) {
+ big_waste_of_time();
+ }
+
+ A conflict occurs if both **-bl** and **-bar** are specified.
+
+- **-otr**, **--opening-token-right** and related flags
+
+ The **-otr** flag is a hint that perltidy should not place a break between a
+ comma and an opening token. For example:
+
+ # default formatting
+ push @{ $self->{$module}{$key} },
+ {
+ accno => $ref->{accno},
+ description => $ref->{description}
+ };
+
+ # perltidy -otr
+ push @{ $self->{$module}{$key} }, {
+ accno => $ref->{accno},
+ description => $ref->{description}
+ };
+
+ The flag **-otr** is actually an abbreviation for three other flags
+ which can be used to control parens, hash braces, and square brackets
+ separately if desired:
+
+ -opr or --opening-paren-right
+ -ohbr or --opening-hash-brace-right
+ -osbr or --opening-square-bracket-right
+
+- **-wn**, **--weld-nested-containers**
+
+ The **-wn** flag causes closely nested pairs of opening and closing container
+ symbols (curly braces, brackets, or parens) to be "welded" 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.
+
+ For example:
+
+ # default formatting
+ do {
+ {
+ next if $x == $y;
+ }
+ } until $x++ > $z;
+
+ # perltidy -wn
+ do { {
+ next if $x == $y;
+ } } until $x++ > $z;
+
+ 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.
+
+ 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:
+
+ # default formatting
+ my (@date_time) = Localtime(
+ Date_to_Time(
+ Add_Delta_DHMS(
+ $year, $month, $day, $hour, $minute, $second,
+ '0', $offset, '0', '0'
+ )
+ )
+ );
+
+ # perltidy -wn
+ my (@date_time) = Localtime( Date_to_Time( Add_Delta_DHMS(
+ $year, $month, $day, $hour, $minute, $second,
+ '0', $offset, '0', '0'
+ ) ) );
+
+ 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 "meat" of the sandwich, and a final closing layer. This
+ predictable structure helps keep the compacted structure readable.
+
+ 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 **-conv** flag can be used to insure that the final format is
+ achieved in a single run.
+
+ Here is an example illustrating a welded container within a welded containers:
+
+ # default formatting
+ $x->badd(
+ bmul(
+ $class->new(
+ abs(
+ $sx * int( $xr->numify() ) & $sy * int( $yr->numify() )
+ )
+ ),
+ $m
+ )
+ );
+
+ # perltidy -wn
+ $x->badd( bmul(
+ $class->new( abs(
+ $sx * int( $xr->numify() ) & $sy * int( $yr->numify() )
+ ) ),
+ $m
+ ) );
+
+ This format option is quite general but there are some limitations.
+
+ One limitiation is that any line length limit still applies and can cause long
+ welded sections to be broken into multiple lines.
+
+ 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.
+
+ 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.
+
+- **Vertical tightness** of non-block curly braces, parentheses, and square brackets.
+
+ These parameters control what shall be called vertical tightness. Here are the
+ main points:
+
+ - Opening tokens (except for block braces) are controlled by **-vt=n**, or
+ **--vertical-tightness=n**, where
+
+ -vt=0 always break a line after opening token (default).
+ -vt=1 do not break unless this would produce more than one
+ step in indentation in a line.
+ -vt=2 never break a line after opening token
+
+ - You must also use the **-lp** flag when you use the **-vt** flag; the
+ reason is explained below.
+ - Closing tokens (except for block braces) are controlled by **-vtc=n**, or
+ **--vertical-tightness-closing=n**, where
+
+ -vtc=0 always break a line before a closing token (default),
+ -vtc=1 do not break before a closing token which is followed
+ by a semicolon or another closing token, and is not in
+ a list environment.
+ -vtc=2 never break before a closing token.
+
+ The rules for **-vtc=1** are designed to maintain a reasonable balance
+ between tightness and readability in complex lists.
+
+ - Different controls may be applied to different token types,
+ and it is also possible to control block braces; see below.
+ - 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 **-lp** parameter.
+ Also, these flags may be ignored for very small lists (2 or 3 lines in
+ length).
+
+ Here are some examples:
+
+ # perltidy -lp -vt=0 -vtc=0
+ %romanNumerals = (
+ one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV',
+ );
+
+ # perltidy -lp -vt=1 -vtc=0
+ %romanNumerals = ( one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV',
+ );
+
+ # perltidy -lp -vt=1 -vtc=1
+ %romanNumerals = ( one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV', );
+
+ The difference between **-vt=1** and **-vt=2** is shown here:
+
+ # perltidy -lp -vt=1
+ $init->add(
+ mysprintf( "(void)find_threadsv(%s);",
+ cstring( $threadsv_names[ $op->targ ] )
+ )
+ );
+
+ # perltidy -lp -vt=2
+ $init->add( mysprintf( "(void)find_threadsv(%s);",
+ cstring( $threadsv_names[ $op->targ ] )
+ )
+ );
+
+ With **-vt=1**, the line ending in `add(` does not combine with the next
+ line because the next line is not balanced. This can help with
+ readability, but **-vt=2** can be used to ignore this rule.
+
+ The tightest, and least readable, code is produced with both `-vt=2` and
+ `-vtc=2`:
+
+ # perltidy -lp -vt=2 -vtc=2
+ $init->add( mysprintf( "(void)find_threadsv(%s);",
+ cstring( $threadsv_names[ $op->targ ] ) ) );
+
+ Notice how the code in all of these examples collapses vertically as
+ **-vt** increases, but the indentation remains unchanged. This is
+ because perltidy implements the **-vt** parameter by first formatting as
+ if **-vt=0**, and then simply overwriting one output line on top of the
+ next, if possible, to achieve the desired vertical tightness. The
+ **-lp** indentation style has been designed to allow this vertical
+ collapse to occur, which is why it is required for the **-vt** parameter.
+
+ The **-vt=n** and **-vtc=n** 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.
+
+ The parameters for controlling parentheses are **-pvt=n** or
+ **--paren-vertical-tightness=n**, and **-pcvt=n** or
+ **--paren-vertical-tightness-closing=n**.
+
+ Likewise, the parameters for square brackets are **-sbvt=n** or
+ **--square-bracket-vertical-tightness=n**, and **-sbcvt=n** or
+ **--square-bracket-vertical-tightness-closing=n**.
+
+ Finally, the parameters for controlling non-code block braces are
+ **-bvt=n** or **--brace-vertical-tightness=n**, and **-bcvt=n** or
+ **--brace-vertical-tightness-closing=n**.
+
+ In fact, the parameter **-vt=n** is actually just an abbreviation for
+ **-pvt=n -bvt=n sbvt=n**, and likewise **-vtc=n** is an abbreviation
+ for **-pvtc=n -bvtc=n sbvtc=n**.
+
+- **-bbvt=n** or **--block-brace-vertical-tightness=n**
+
+ The **-bbvt=n** flag is just like the **-vt=n** flag but applies
+ to opening code block braces.
+
+ -bbvt=0 break after opening block brace (default).
+ -bbvt=1 do not break unless this would produce more than one
+ step in indentation in a line.
+ -bbvt=2 do not break after opening block brace.
+
+ It is necessary to also use either **-bl** or **-bli** 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:
+
+ # perltidy -bli -bbvt=0
+ if ( open( FILE, "< $File" ) )
+ {
+ while ( $File = <FILE> )
+ {
+ $In .= $File;
+ $count++;
+ }
+ close(FILE);
+ }
+
+ # perltidy -bli -bbvt=1
+ if ( open( FILE, "< $File" ) )
+ { while ( $File = <FILE> )
+ { $In .= $File;
+ $count++;
+ }
+ close(FILE);
+ }
+
+ By default this applies to blocks associated with keywords **if**,
+ **elsif**, **else**, **unless**, **for**, **foreach**, **sub**, **while**,
+ **until**, and also with a preceding label. This can be changed with
+ the parameter **-bbvtl=string**, or
+ **--block-brace-vertical-tightness-list=string**, where **string** is a
+ space-separated list of block types. For more information on the
+ possible values of this string, see ["Specifying Block Types"](#specifying-block-types)
+
+ For example, if we want to just apply this style to `if`,
+ `elsif`, and `else` blocks, we could use
+ `perltidy -bli -bbvt=1 -bbvtl='if elsif else'`.
+
+ 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 **-scbb**.
+
+- **-sot**, **--stack-opening-tokens** and related flags
+
+ The **-sot** flag tells perltidy to "stack" opening tokens
+ when possible to avoid lines with isolated opening tokens.
+
+ For example:
+
+ # default
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+ # -sot
+ $opt_c = Text::CSV_XS->new( {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+ For detailed control of individual closing tokens the following
+ controls can be used:
+
+ -sop or --stack-opening-paren
+ -sohb or --stack-opening-hash-brace
+ -sosb or --stack-opening-square-bracket
+ -sobb or --stack-opening-block-brace
+
+ The flag **-sot** is an abbreviation for **-sop -sohb -sosb**.
+
+ The flag **-sobb** is a abbreviation for **-bbvt=2 -bbvtl='\*'**. This
+ will case a cascade of opening block braces to appear on a single line,
+ although this an uncommon occurrence except in test scripts.
+
+- **-sct**, **--stack-closing-tokens** and related flags
+
+ The **-sct** flag tells perltidy to "stack" closing tokens
+ when possible to avoid lines with isolated closing tokens.
+
+ For example:
+
+ # default
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+ # -sct
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ } );
+
+ The **-sct** flag is somewhat similar to the **-vtc** flags, and in some
+ cases it can give a similar result. The difference is that the **-vtc**
+ flags try to avoid lines with leading opening tokens by "hiding" them at
+ the end of a previous line, whereas the **-sct** 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:
+
+ # -vtc=2
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1, } );
+
+ For detailed control of the stacking of individual closing tokens the
+ following controls can be used:
+
+ -scp or --stack-closing-paren
+ -schb or --stack-closing-hash-brace
+ -scsb or --stack-closing-square-bracket
+ -scbb or --stack-closing-block-brace
+
+ The flag **-sct** is an abbreviation for stacking the non-block closing
+ tokens, **-scp -schb -scsb**.
+
+ Stacking of closing block braces, **-scbb**, causes a cascade of isolated
+ closing block braces to be combined into a single line as in the following
+ example:
+
+ # -scbb:
+ for $w1 (@w1) {
+ for $w2 (@w2) {
+ for $w3 (@w3) {
+ for $w4 (@w4) {
+ push( @lines, "$w1 $w2 $w3 $w4\n" );
+ } } } }
+
+ To simplify input even further for the case in which both opening and closing
+ non-block containers are stacked, the flag **-sac** or **--stack-all-containers**
+ is an abbreviation for **-sot -sot**.
+
+- **-dnl**, **--delete-old-newlines**
+
+ 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 **-ndnl**
+ or **--nodelete-old-newlines** to force perltidy to retain all old line break
+ points.
+
+- **-anl**, **--add-newlines**
+
+ By default, perltidy will add line breaks when necessary to create
+ continuations of long lines and to improve the script appearance. Use
+ **-nanl** or **--noadd-newlines** to prevent any new line breaks.
+
+ This flag does not prevent perltidy from eliminating existing line
+ breaks; see **--freeze-newlines** to completely prevent changes to line
+ break points.
+
+- Controlling whether perltidy breaks before or after operators
+
+ 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:
+
+ **-wba=s** or **--want-break-after=s**, and
+
+ **-wbb=s** or **--want-break-before=s**.
+
+ These parameters are each followed by a quoted string, **s**, 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.
+
+ By default, perltidy breaks **after** these token types:
+ % + - \* / x != == >= <= =~ !~ < > | &
+ = \*\*= += \*= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
+
+ And perltidy breaks **before** these token types by default:
+ . << >> -> && || //
+
+ To illustrate, to cause a break after a concatenation operator, `'.'`,
+ rather than before it, the command line would be
+
+ -wba="."
+
+ As another example, the following command would cause a break before
+ math operators `'+'`, `'-'`, `'/'`, and `'*'`:
+
+ -wbb="+ - / *"
+
+ These commands should work well for most of the token types that perltidy uses
+ (use **--dump-token-types** for a list). Also try the **-D** 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 **bl** provided for that purpose.
+
+ **WARNING** Be sure to put these tokens in quotes to avoid having them
+ misinterpreted by your command shell.
+
+ Two additional parameters are available which, though they provide no further
+ capability, can simplify input are:
+
+ **-baao** or **--break-after-all-operators**,
+
+ **-bbao** or **--break-before-all-operators**.
+
+ The -baao sets the default to be to break after all of the following operators:
+
+ % + - * / x != == >= <= =~ !~ < > | &
+ = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
+ . : ? && || and or err xor
+
+ and the **-bbao** 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 **-wba** and **-wbb** flags. For example, to break before all operators
+ except an **=** one could use --bbao -wba='=' rather than listing every
+ single perl operator except **=** on a -wbb flag.
+
+## Controlling List Formatting
+
+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.
+
+- **-boc**, **--break-at-old-comma-breakpoints**
+
+ 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:
+
+ my @list = (1,
+ 1, 1,
+ 1, 2, 1,
+ 1, 3, 3, 1,
+ 1, 4, 6, 4, 1,);
+
+ The default formatting will flatten this down to one line:
+
+ # perltidy (default)
+ my @list = ( 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1, );
+
+ which hides the structure. Using **-boc**, plus additional flags
+ to retain the original style, yields
+
+ # perltidy -boc -lp -pt=2 -vt=1 -vtc=1
+ my @list = (1,
+ 1, 1,
+ 1, 2, 1,
+ 1, 3, 3, 1,
+ 1, 4, 6, 4, 1,);
+
+ 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 ["Skipping Selected Sections of Code"](#skipping-selected-sections-of-code).
+
+- **-mft=n**, **--maximum-fields-per-table=n**
+
+ If the computed number of fields for any table exceeds **n**, then it
+ will be reduced to **n**. The default value for **n** 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 **-boc**
+ 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.
+
+ # perltidy -mft=2
+ @month_of_year = (
+ 'Jan', 'Feb',
+ 'Mar', 'Apr',
+ 'May', 'Jun',
+ 'Jul', 'Aug',
+ 'Sep', 'Oct',
+ 'Nov', 'Dec'
+ );
+
+- **-cab=n**, **--comma-arrow-breakpoints=n**
+
+ A comma which follows a comma arrow, '=>', 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 **-boc** is used). The possible values of **n** are:
+
+ n=0 break at all commas after =>
+ n=1 stable: break at all commas after => if container is open,
+ EXCEPT FOR one-line containers
+ n=2 break at all commas after =>, BUT try to form the maximum
+ maximum one-line container lengths
+ n=3 do not treat commas after => specially at all
+ n=4 break everything: like n=0 but ALSO break a short container with
+ a => not followed by a comma when -vt=0 is used
+ n=5 stable: like n=1 but ALSO break at open one-line containers when
+ -vt=0 is used (default)
+
+ 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:
+
+ bless { B => $B, Root => $Root } => $package;
+
+ Using **-cab=0** will force a break after each comma-arrow item:
+
+ # perltidy -cab=0:
+ bless {
+ B => $B,
+ Root => $Root
+ } => $package;
+
+ If perltidy is subsequently run with this container broken, then by
+ default it will break after each '=>' because the container is now
+ broken. To reform a one-line container, the parameter **-cab=2** could
+ be used.
+
+ The flag **-cab=3** can be used to prevent these commas from being
+ treated specially. In this case, an item such as "01" => 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.
+
+ # perltidy -cab=3
+ my %last_day = (
+ "01" => 31, "02" => 29, "03" => 31, "04" => 30,
+ "05" => 31, "06" => 30, "07" => 31, "08" => 31,
+ "09" => 30, "10" => 31, "11" => 30, "12" => 31
+ );
+
+## Retaining or Ignoring Existing Line Breaks
+
+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.
+
+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.
+
+- **-bol**, **--break-at-old-logical-breakpoints**
+
+ By default, if a logical expression is broken at a `&&`, `||`, `and`,
+ or `or`, then the container will remain broken. Also, breaks
+ at internal keywords `if` and `unless` will normally be retained.
+ To prevent this, and thus form longer lines, use **-nbol**.
+
+- **-bok**, **--break-at-old-keyword-breakpoints**
+
+ By default, perltidy will retain a breakpoint before keywords which may
+ return lists, such as `sort` and <map>. This allows chains of these
+ operators to be displayed one per line. Use **-nbok** to prevent
+ retaining these breakpoints.
+
+- **-bot**, **--break-at-old-ternary-breakpoints**
+
+ By default, if a conditional (ternary) operator is broken at a `:`,
+ then it will remain broken. To prevent this, and thereby
+ form longer lines, use **-nbot**.
+
+- **-boa**, **--break-at-old-attribute-breakpoints**
+
+ By default, if an attribute list is broken at a `:` in the source file, then
+ it will remain broken. For example, given the following code, the line breaks
+ at the ':'s will be retained:
+
+ my @field
+ : field
+ : Default(1)
+ : Get('Name' => 'foo') : Set('Name');
+
+ If the attributes are on a single line in the source code then they will remain
+ on a single line if possible.
+
+ To prevent this, and thereby always form longer lines, use **-nboa**.
+
+- **-iob**, **--ignore-old-breakpoints**
+
+ 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.
+
+- **-kis**, **--keep-interior-semicolons**
+
+ Use the **-kis** 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:
+
+ dbmclose(%verb_delim); undef %verb_delim;
+ dbmclose(%expanded); undef %expanded;
+
+ The default is to break after each statement, giving
+
+ dbmclose(%verb_delim);
+ undef %verb_delim;
+ dbmclose(%expanded);
+ undef %expanded;
+
+ With **perltidy -kis** the multiple statements are retained:
+
+ dbmclose(%verb_delim); undef %verb_delim;
+ dbmclose(%expanded); undef %expanded;
+
+ The statements are still subject to the specified value
+ of **maximum-line-length** and will be broken if this
+ maximum is exceeded.
+
+## Blank Line Control
+
+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.
+
+- **-fbl**, **--freeze-blank-lines**
+
+ Set **-fbl** 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 **-fbl** flag
+ is equivalent to setting **-mbl=0** and **-kbl=2**).
+
+- **-bbc**, **--blanks-before-comments**
+
+ A blank line will be introduced before a full-line comment. This is the
+ default. Use **-nbbc** or **--noblanks-before-comments** to prevent
+ such blank lines from being introduced.
+
+- **-blbs=n**, **--blank-lines-before-subs=n**
+
+ The parameter **-blbs=n** requests that least **n** blank lines precede a sub
+ definition which does not follow a comment and which is more than one-line
+ long. The default is <-blbs=1>. **BEGIN** and **END** blocks are included.
+
+ The requested number of blanks statement will be inserted regardless of the
+ value of **--maximum-consecutive-blank-lines=n** (**-mbl=n**) with the exception
+ that if **-mbl=0** then no blanks will be output.
+
+ This parameter interacts with the value **k** of the parameter **--maximum-consecutive-blank-lines=k** (**-mbl=k**) as follows:
+
+ 1\. If **-mbl=0** then no blanks will be output. This allows all blanks to be suppressed with a single parameter. Otherwise,
+
+ 2\. If the number of old blank lines in the script is less than **n** then
+ additional blanks will be inserted to make the total **n** regardless of the
+ value of **-mbl=k**.
+
+ 3\. If the number of old blank lines in the script equals or exceeds **n** then
+ this parameter has no effect, however the total will not exceed
+ value specified on the **-mbl=k** flag.
+
+- **-blbp=n**, **--blank-lines-before-packages=n**
+
+ The parameter **-blbp=n** requests that least **n** blank lines precede a package
+ which does not follow a comment. The default is **-blbp=1**.
+
+ This parameter interacts with the value **k** of the parameter
+ **--maximum-consecutive-blank-lines=k** (**-mbl=k**) in the same way as described
+ for the previous item **-blbs=n**.
+
+- **-bbs**, **--blanks-before-subs**
+
+ For compatibility with previous versions, **-bbs** or **--blanks-before-subs**
+ is equivalent to `-blbp=1` and `-blbs=1`.
+
+ Likewise, **-nbbs** or **--noblanks-before-subs**
+ is equivalent to `-blbp=0` and `-blbs=0`.
+
+- **-bbb**, **--blanks-before-blocks**
+
+ A blank line will be introduced before blocks of coding delimited by
+ **for**, **foreach**, **while**, **until**, and **if**, **unless**, in the following
+ circumstances:
+
+ - The block is not preceded by a comment.
+ - The block is not a one-line block.
+ - The number of consecutive non-blank lines at the current indentation depth is at least **-lbl**
+ (see next section).
+
+ This is the default. The intention of this option is to introduce
+ some space within dense coding.
+ This is negated with **-nbbb** or **--noblanks-before-blocks**.
+
+- **-lbl=n** **--long-block-line-count=n**
+
+ 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 **0** is equivalent to entering a very large number.
+
+- **-blao=i** or **--blank-lines-after-opening-block=i**
+
+ This control places a minimum of **i** blank lines **after** a line which **ends**
+ with an opening block brace of a specified type. By default, this only applies
+ to the block of a named **sub**, but this can be changed (see **-blaol** below).
+ The default is not to do this (**i=0**).
+
+ Please see the note below on using the **-blao** and **-blbc** options.
+
+- **-blbc=i** or **--blank-lines-before-closing-block=i**
+
+ This control places a minimum of **i** blank lines **before** a line which
+ **begins** with a closing block brace of a specified type. By default, this
+ only applies to the block of a named **sub**, but this can be changed (see
+ **-blbcl** below). The default is not to do this (**i=0**).
+
+- **-blaol=s** or **--blank-lines-after-opening-block-list=s**
+
+ The parameter **s** is a list of block type keywords to which the flag **-blao**
+ should apply. The section ["Specifying Block Types"](#specifying-block-types) explains how to list
+ block types.
+
+- **-blbcl=s** or **--blank-lines-before-closing-block-list=s**
+
+ This parameter is a list of block type keywords to which the flag **-blbc**
+ should apply. The section ["Specifying Block Types"](#specifying-block-types) explains how to list
+ block types.
+
+- Note on using the **-blao** and **-blbc** options.
+
+ 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.
+
+ 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
+
+ perltidy -blao=2 -blbc=2 -blaol='*' -blbcl='*' filename
+
+ Now suppose the script continues to be developed, but at some later date we
+ decide we don't want these spaces after all. we might expect that running with
+ the flags **-blao=0** and **-blbc=0** will undo them. However, by default
+ perltidy retains single blank lines, so the blank lines remain.
+
+ We can easily fix this by telling perltidy to ignore old blank lines by
+ including the added parameter **-kbl=0** 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.
+
+- **-mbl=n** **--maximum-consecutive-blank-lines=n**
+
+ 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 **-blbp** and **-blbs** parameters. If **n=0**
+ then no blank lines will be output (unless all old blank lines are retained
+ with the **-kbl=2** flag of the next section).
+
+ This flag obviously does not apply to pod sections,
+ here-documents, and quotes.
+
+- **-kbl=n**, **--keep-old-blank-lines=n**
+
+ The **-kbl=n** flag gives you control over how your existing blank lines are
+ treated.
+
+ The possible values of **n** are:
+
+ n=0 ignore all old blank lines
+ n=1 stable: keep old blanks, but limited by the value of the B<-mbl=n> flag
+ n=2 keep all old blank lines, regardless of the value of the B<-mbl=n> flag
+
+ The default is **n=1**.
+
+- **-sob**, **--swallow-optional-blank-lines**
+
+ This is equivalent to **kbl=0** and is included for compatibility with
+ previous versions.
+
+- **-nsob**, **--noswallow-optional-blank-lines**
+
+ This is equivalent to **kbl=1** and is included for compatibility with
+ previous versions.
+
+## Styles
+
+A style refers to a convenient collection of existing parameters.
+
+- **-gnu**, **--gnu-style**
+
+ **-gnu** 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:
+
+ -lp -bl -noll -pt=2 -bt=2 -sbt=2 -icp
+
+- **-pbp**, **--perl-best-practices**
+
+ **-pbp** is an abbreviation for the parameters in the book **Perl Best Practices**
+ by Damian Conway:
+
+ -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
+ -wbb="% + - * / x != == >= <= =~ !~ < > | & =
+ **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
+
+ 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
+ **-nst** and/or **-nse** after the -pbp parameter.
+
+ 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,
+
+ # perltidy -pbp
+ $self->{_text} = (
+ !$section ? ''
+ : $type eq 'item' ? "the $section entry"
+ : "the section on $section"
+ )
+ . (
+ $page
+ ? ( $section ? ' in ' : '' ) . "the $page$page_ext manpage"
+ : ' elsewhere in this document'
+ );
+
+ # perltidy -pbp -ci=2
+ $self->{_text} = (
+ !$section ? ''
+ : $type eq 'item' ? "the $section entry"
+ : "the section on $section"
+ )
+ . (
+ $page
+ ? ( $section ? ' in ' : '' ) . "the $page$page_ext manpage"
+ : ' elsewhere in this document'
+ );
+
+## Controlling Vertical Alignment
+
+Vertical alignment refers to lining up certain symbols in list of consecutive
+similar lines to improve readability. For example, the "fat commas" are
+aligned in the following statement:
+
+ $data = $pkg->new(
+ PeerAddr => join( ".", @port[ 0 .. 3 ] ),
+ PeerPort => $port[4] * 256 + $port[5],
+ Proto => 'tcp'
+ );
+
+The only explicit control on vertical alignment is to turn it off using
+**-novalign**, 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.
+
+ %option_range = (
+ 'format' => [ 'tidy', 'html', 'user' ],
+ 'output-line-ending' => [ 'dos', 'win', 'mac', 'unix' ],
+ 'character-encoding' => [ 'none', 'utf8' ],
+
+ 'block-brace-tightness' => [ 0, 2 ],
+ 'brace-tightness' => [ 0, 2 ],
+ 'paren-tightness' => [ 0, 2 ],
+ 'square-bracket-tightness' => [ 0, 2 ],
+ );
+
+## Other Controls
+
+- Deleting selected text
+
+ Perltidy can selectively delete comments and/or pod documentation. The
+ command **-dac** or **--delete-all-comments** will delete all comments
+ **and** all pod documentation, leaving just code and any leading system
+ control lines.
+
+ The command **-dp** or **--delete-pod** will remove all pod documentation
+ (but not comments).
+
+ Two commands which remove comments (but not pod) are: **-dbc** or
+ **--delete-block-comments** and **-dsc** or **--delete-side-comments**.
+ (Hanging side comments will be deleted with block comments here.)
+
+ The negatives of these commands also work, and are the defaults. When
+ block comments are deleted, any leading 'hash-bang' will be retained.
+ Also, if the **-x** flag is used, any system commands before a leading
+ hash-bang will be retained (even if they are in the form of comments).
+
+- Writing selected text to a file
+
+ When perltidy writes a formatted text file, it has the ability to also
+ send selected text to a file with a `.TEE` extension. This text can
+ include comments and pod documentation.
+
+ The command **-tac** or **--tee-all-comments** will write all comments
+ **and** all pod documentation.
+
+ The command **-tp** or **--tee-pod** will write all pod documentation (but
+ not comments).
+
+ The commands which write comments (but not pod) are: **-tbc** or
+ **--tee-block-comments** and **-tsc** or **--tee-side-comments**.
+ (Hanging side comments will be written with block comments here.)
+
+ The negatives of these commands also work, and are the defaults.
+
+- Using a `.perltidyrc` command file
+
+ If you use perltidy frequently, you probably won't be happy until you
+ create a `.perltidyrc` file to avoid typing commonly-used parameters.
+ Perltidy will first look in your current directory for a command file
+ named `.perltidyrc`. If it does not find one, it will continue looking
+ for one in other standard locations.
+
+ These other locations are system-dependent, and may be displayed with
+ the command `perltidy -dpro`. Under Unix systems, it will first look
+ for an environment variable **PERLTIDY**. Then it will look for a
+ `.perltidyrc` file in the home directory, and then for a system-wide
+ file `/usr/local/etc/perltidyrc`, and then it will look for
+ `/etc/perltidyrc`. 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.
+
+ Under Windows, perltidy will also search for a configuration file named perltidy.ini since Windows does not allow files with a leading period (.).
+ Use `perltidy -dpro` to see the possible locations for your system.
+ An example might be `C:\Documents and Settings\All Users\perltidy.ini`.
+
+ 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:
+
+ http://www.netmanage.com/000/20021101\_005\_tcm21-6336.pdf
+
+ 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
+
+ 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.
+
+ Here is an example of a `.perltidyrc` file:
+
+ # This is a simple of a .perltidyrc configuration file
+ # This implements a highly spaced style
+ -se # errors to standard error output
+ -w # show all warnings
+ -bl # braces on new lines
+ -pt=0 # parens not tight at all
+ -bt=0 # braces not tight
+ -sbt=0 # square brackets not tight
+
+ The parameters in the `.perltidyrc` file are installed first, so any
+ parameters given on the command line will have priority over them.
+
+ To avoid confusion, perltidy ignores any command in the .perltidyrc
+ file which would cause some kind of dump and an exit. These are:
+
+ -h -v -ddf -dln -dop -dsn -dtt -dwls -dwrs -ss
+
+ There are several options may be helpful in debugging a `.perltidyrc`
+ file:
+
+ - A very helpful command is **--dump-profile** or **-dpro**. 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
+
+ perltidy -dpro
+
+ - It may be simplest to develop and test configuration files with
+ alternative names, and invoke them with **-pro=filename** on the command
+ line. Then rename the desired file to `.perltidyrc` when finished.
+ - The parameters in the `.perltidyrc` file can be switched off with
+ the **-npro** option.
+ - The commands **--dump-options**, **--dump-defaults**, **--dump-long-names**,
+ and **--dump-short-names**, all described below, may all be helpful.
+
+- Creating a new abbreviation
+
+ A special notation is available for use in a `.perltidyrc` 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:
+
+ newword {
+ -opt1
+ -opt2
+ }
+
+ where **newword** is the abbreviation, and **opt1**, etc, are existing parameters
+ _or other abbreviations_. 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
+
+ airy {-bl -pt=0 -bt=0 -sbt=0}
+
+ could be placed in a `.perltidyrc` file, and then invoked at will with
+
+ perltidy -airy somefile.pl
+
+ (Either `-airy` or `--airy` may be used).
+
+- Skipping leading non-perl commands with **-x** or **--look-for-hash-bang**
+
+ 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 "hash-bang" line, ( a line of the form `#!...perl` ),
+ you must use the **-x** flag to tell perltidy not to parse and format any
+ lines before the "hash-bang" 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 `perl -x`.
+
+- Making a file unreadable
+
+ The goal of perltidy is to improve the readability of files, but there
+ are two commands which have the opposite effect, **--mangle** and
+ **--extrude**. 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 **--mangle** puts the fewest possible
+ line breaks in a script while **--extrude** 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 **--mangle** is the following:
+
+ perltidy --mangle myfile.pl -st | perltidy -o myfile.pl.new
+
+ This will form the maximum possible number of one-line blocks (see next
+ section), and can sometimes help clean up a badly formatted script.
+
+ A similar technique can be used with **--extrude** instead of **--mangle**
+ to make the minimum number of one-line blocks.
+
+ Another use for **--mangle** is to combine it with **-dac** to reduce
+ the file size of a perl script.
+
+- One-line blocks
+
+ There are a few points to note regarding one-line blocks. A one-line
+ block is something like this,
+
+ if ($x > 0) { $y = 1 / $x }
+
+ where the contents within the curly braces is short enough to fit
+ on a single line.
+
+ 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.
+
+ 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 **-nasc**
+ option is used) if the block is a code block.
+
+ The main exception is that perltidy will attempt to form new one-line
+ blocks following the keywords `map`, `eval`, and `sort`, because
+ these code blocks are often small and most clearly displayed in a single
+ line.
+
+ 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.
+
+ 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.
+
+- Debugging
+
+ The following flags are available for debugging:
+
+ **--dump-cuddled-block-list** or **-dcbl** will dump to standard output the
+ internal hash of cuddled block types created by a **-cuddled-block-list** input
+ string.
+
+ **--dump-defaults** or **-ddf** will write the default option set to standard output and quit
+
+ **--dump-profile** or **-dpro** will write the name of the current
+ configuration file and its contents to standard output and quit.
+
+ **--dump-options** or **-dop** will write current option set to standard
+ output and quit.
+
+ **--dump-long-names** or **-dln** will write all command line long names (passed
+ to Get\_options) to standard output and quit.
+
+ **--dump-short-names** or **-dsn** will write all command line short names
+ to standard output and quit.
+
+ **--dump-token-types** or **-dtt** will write a list of all token types
+ to standard output and quit.
+
+ **--dump-want-left-space** or **-dwls** will write the hash %want\_left\_space
+ to standard output and quit. See the section on controlling whitespace
+ around tokens.
+
+ **--dump-want-right-space** or **-dwrs** will write the hash %want\_right\_space
+ to standard output and quit. See the section on controlling whitespace
+ around tokens.
+
+ **--no-memoize** or **-nmem** 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 **-nmem**.
+
+ **--no-timestamp** or **-nts** 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 **-cscw** option is selected. The default is
+ to allow timestamps (**--timestamp** or **-ts**).
+
+ **--file-size-order** or **-fso** 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.
+
+ **-DEBUG** will write a file with extension `.DEBUG` for each input file
+ showing the tokenization of all lines of code.
+
+- Working with MakeMaker, AutoLoader and SelfLoader
+
+ The first $VERSION line of a file which might be eval'd by MakeMaker
+ is passed through unchanged except for indentation.
+ Use **--nopass-version-line**, or **-npvl**, to deactivate this feature.
+
+ If the AutoLoader module is used, perltidy will continue formatting
+ code after seeing an \_\_END\_\_ line.
+ Use **--nolook-for-autoloader**, or **-nlal**, to deactivate this feature.
+
+ Likewise, if the SelfLoader module is used, perltidy will continue formatting
+ code after seeing a \_\_DATA\_\_ line.
+ Use **--nolook-for-selfloader**, or **-nlsl**, to deactivate this feature.
+
+- Working around problems with older version of Perl
+
+ 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 `use strict` is active.
+
+ There is no way to override these rules.
+
+# HTML OPTIONS
+
+- The **-html** master switch
+
+ The flag **-html** causes perltidy to write an html file with extension
+ `.html`. So, for example, the following command
+
+ perltidy -html somefile.pl
+
+ will produce a syntax-colored html file named `somefile.pl.html`
+ which may be viewed with a browser.
+
+ **Please Note**: In this case, perltidy does not do any formatting to the
+ input file, and it does not write a formatted file with extension
+ `.tdy`. This means that two perltidy runs are required to create a
+ fully reformatted, html copy of a script.
+
+- The **-pre** flag for code snippets
+
+ When the **-pre** flag is given, only the pre-formatted section, within
+ the <PRE> and </PRE> tags, will be output. This simplifies inclusion
+ of the output in other files. The default is to output a complete
+ web page.
+
+- The **-nnn** flag for line numbering
+
+ When the **-nnn** flag is given, the output lines will be numbered.
+
+- The **-toc**, or **--html-table-of-contents** flag
+
+ By default, a table of contents to packages and subroutines will be
+ written at the start of html output. Use **-ntoc** 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).
+
+- The **-pod**, or **--pod2html** flag
+
+ 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 ["FILES"](#files). Also, Pod::Html creates temporary
+ files for its cache.
+
+ NOTE: Perltidy counts the number of `=cut` lines, and either moves the
+ pod text to the top of the html file if there is one `=cut`, or leaves
+ the pod text in its original order (interleaved with code) otherwise.
+
+ 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 `pod` 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 `pod` prefix are:
+
+ --[no]podheader --[no]podindex --[no]podrecurse --[no]podquiet
+ --[no]podverbose --podflush
+
+ The flags which are unchanged from their use in pod2html are:
+
+ --backlink=s --cachedir=s --htmlroot=s --libpods=s --title=s
+ --podpath=s --podroot=s
+
+ where 's' 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.
+
+ The alternative, indicated with **-npod**, 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.
+
+- The **-frm**, or **--frames** flag
+
+ By default, a single html output file is produced. This can be changed
+ with the **-frm** 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
+ `MyModule.pm`. Then, for default file extension choices, these three
+ files will be created:
+
+ MyModule.pm.html - the frame
+ MyModule.pm.toc.html - the table of contents
+ MyModule.pm.src.html - the formatted source code
+
+ 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 **-frm** option will be
+ ignored.
+
+- The **-text=s**, or **--html-toc-extension** flag
+
+ Use this flag to specify the extra file extension of the table of contents file
+ when html frames are used. The default is "toc".
+ See ["Specifying File Extensions"](#specifying-file-extensions).
+
+- The **-sext=s**, or **--html-src-extension** flag
+
+ Use this flag to specify the extra file extension of the content file when html
+ frames are used. The default is "src".
+ See ["Specifying File Extensions"](#specifying-file-extensions).
+
+- The **-hent**, or **--html-entities** flag
+
+ 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.
+
+- Style Sheets
+
+ 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.
+
+ 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
+ **-css=filename**, where the external style sheet is `filename`. The
+ external style sheet `filename` will be created if and only if it does
+ not exist. This option is useful for controlling multiple pages from a
+ single style sheet.
+
+ To cause perltidy to write a style sheet to standard output and exit,
+ use the **-ss**, or **--stylesheet**, flag. This is useful if the style
+ sheet could not be written for some reason, such as if the **-pre** flag
+ was used. Thus, for example,
+
+ perltidy -html -ss >mystyle.css
+
+ will write a style sheet with the default properties to file
+ `mystyle.css`.
+
+ The use of style sheets is encouraged, but a web page without a style
+ sheets can be created with the flag **-nss**. 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.
+
+- Controlling HTML properties
+
+ 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.
+
+ Syntax colors may be changed from their default values by flags of the either
+ the long form, **-html-color-xxxxxx=n**, or more conveniently the short form,
+ **-hcx=n**, where **xxxxxx** is one of the following words, and **x** is the
+ corresponding abbreviation:
+
+ Token Type xxxxxx x
+ ---------- -------- --
+ comment comment c
+ number numeric n
+ identifier identifier i
+ bareword, function bareword w
+ keyword keyword k
+ quite, pattern quote q
+ here doc text here-doc-text h
+ here doc target here-doc-target hh
+ punctuation punctuation pu
+ parentheses paren p
+ structural braces structure s
+ semicolon semicolon sc
+ colon colon co
+ comma comma cm
+ label label j
+ sub definition name subroutine m
+ pod text pod-text pd
+
+ A default set of colors has been defined, but they may be changed by providing
+ values to any of the following parameters, where **n** is either a 6 digit
+ hex RGB color value or an ascii name for a color, such as 'red'.
+
+ To illustrate, the following command will produce an html
+ file `somefile.pl.html` with "aqua" keywords:
+
+ perltidy -html -hck=00ffff somefile.pl
+
+ and this should be equivalent for most browsers:
+
+ perltidy -html -hck=aqua somefile.pl
+
+ 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:
+
+ black => 000000,
+ silver => c0c0c0,
+ gray => 808080,
+ white => ffffff,
+ maroon => 800000,
+ red => ff0000,
+ purple => 800080,
+ fuchsia => ff00ff,
+ green => 008000,
+ lime => 00ff00,
+ olive => 808000,
+ yellow => ffff00
+ navy => 000080,
+ blue => 0000ff,
+ teal => 008080,
+ aqua => 00ffff,
+
+ 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 "HTML color tables".
+
+ Besides color, two other character attributes may be set: bold, and italics.
+ To set a token type to use bold, use the flag
+ **--html-bold-xxxxxx** or **-hbx**, where **xxxxxx** or **x** are the long
+ or short names from the above table. Conversely, to set a token type to
+ NOT use bold, use **--nohtml-bold-xxxxxx** or **-nhbx**.
+
+ Likewise, to set a token type to use an italic font, use the flag
+ **--html-italic-xxxxxx** or **-hix**, where again **xxxxxx** or **x** are the
+ long or short names from the above table. And to set a token type to
+ NOT use italics, use **--nohtml-italic-xxxxxx** or **-nhix**.
+
+ For example, to use bold braces and lime color, non-bold, italics keywords the
+ following command would be used:
+
+ perltidy -html -hbs -hck=00FF00 -nhbk -hik somefile.pl
+
+ The background color can be specified with **--html-color-background=n**,
+ or **-hcbg=n** for short, where n is a 6 character hex RGB value. The
+ default color of text is the value given to **punctuation**, which is
+ black as a default.
+
+ Here are some notes and hints:
+
+ 1\. If you find a preferred set of these parameters, you may want
+ to create a `.perltidyrc` file containing them. See the perltidy man
+ page for an explanation.
+
+ 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.
+
+ 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.
+
+# SOME COMMON INPUT CONVENTIONS
+
+## Specifying Block Types
+
+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 **if**, **else**, or **sub**.
+An exception is a labeled block, which has no keyword, and should be specified
+with just a colon. To specify all blocks use **'\*'**.
+
+The keyword **sub** indicates a named sub. For anonymous subs, use the special
+keyword **asub**.
+
+For example, the following parameter specifies `sub`, labels, `BEGIN`, and
+`END` blocks:
+
+ -cscl="sub : BEGIN END"
+
+(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:
+
+ -bbvtl='*'
+
+## Specifying File Extensions
+
+Several parameters allow default file extensions to be overridden. For
+example, a backup file extension may be specified with **-bext=ext**,
+where **ext** 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 '.' should be used. If the extension `ext` begins with
+`A-Z`, `a-z`, or `0-9`, then it will be appended to the filename with
+an intermediate '.' (or perhaps an '\_' on VMS systems). Otherwise, it
+will be appended directly.
+
+For example, suppose the file is `somefile.pl`. For `-bext=old`, a '.' is
+added to give `somefile.pl.old`. For `-bext=.old`, no additional '.' is
+added, so again the backup file is `somefile.pl.old`. For `-bext=~`, then no
+dot is added, and the backup file will be `somefile.pl~` .
+
+# SWITCHES WHICH MAY BE NEGATED
+
+The following list shows all short parameter names which allow a prefix
+'n' to produce the negated form:
+
+ D anl asc aws b bbb bbc bbs bl bli boc bok bol bot ce
+ csc dac dbc dcsc ddf dln dnl dop dp dpro dsc dsm dsn dtt dwls
+ dwrs dws f fll frm fs hsc html ibc icb icp iob isbc lal log
+ lp lsl ohbr okw ola oll opr opt osbr otr ple pod pvl q
+ sbc sbl schb scp scsb sct se sfp sfs skp sob sohb sop sosb sot
+ ssc st sts syn t tac tbc toc tp tqw tsc w x bar kis
+
+Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be
+used.
+
+# LIMITATIONS
+
+- Parsing Limitations
+
+ 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.
+
+ The main current limitation is that perltidy does not scan modules
+ included with 'use' 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.
+
+ If you encounter a bug, please report it.
+
+- What perltidy does not parse and format
+
+ Perltidy indents but does not reformat comments and `qw` 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 'format' sections
+ in any way. And, of course, it does not modify pod documents.
+
+# FILES
+
+- Temporary files
+
+ 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 `perltidy.TMP` will be temporarily
+ created in the current working directory.
+
+- Special files when standard input is used
+
+ When standard input is used, the log file, if saved, is `perltidy.LOG`,
+ and any errors are written to `perltidy.ERR` unless the **-se** flag is
+ set. These are saved in the current working directory.
+
+- Files overwritten
+
+ The following file extensions are used by perltidy, and files with these
+ extensions may be overwritten or deleted: `.ERR`, `.LOG`, `.TEE`,
+ and/or `.tdy`, `.html`, and `.bak`, depending on the run type and
+ settings.
+
+- Files extensions limitations
+
+ Perltidy does not operate on files for which the run could produce a file with
+ a duplicated file extension. These extensions include `.LOG`, `.ERR`,
+ `.TEE`, and perhaps `.tdy` and `.bak`, depending on the run type. The
+ purpose of this rule is to prevent generating confusing filenames such as
+ `somefile.tdy.tdy.tdy`.
+
+# SEE ALSO
+
+perlstyle(1), Perl::Tidy(3)
+
+# VERSION
+
+This man page documents perltidy version 20181116
+
+# BUG REPORTS
+
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
+
+To report a new bug or problem, use the link on this page.
+
+The source code repository is at [https://github.com/perltidy/perltidy](https://github.com/perltidy/perltidy).
+
+# COPYRIGHT
+
+Copyright (c) 2000-2018 by Steve Hancock
+
+# LICENSE
+
+This package is free software; you can redistribute it and/or modify it
+under the terms of the "GNU General Public License".
+
+Please refer to the file "COPYING" for details.
+
+# DISCLAIMER
+
+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.
+
+See the "GNU General Public License" for more details.
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#Perltidy-Style-Key">Perltidy Style Key</a>
- <ul>
- <li><a href="#Before-You-Start">Before You Start</a></li>
- <li><a href="#Use-as-Filter">Use as Filter?</a></li>
- <li><a href="#Line-Length-Setting">Line Length Setting</a></li>
- <li><a href="#Indentation-in-Code-Blocks">Indentation in Code Blocks</a></li>
- <li><a href="#Continuation-Indentation">Continuation Indentation</a></li>
- <li><a href="#Tabs">Tabs</a></li>
- <li><a href="#Opening-Block-Brace-Right-or-Left">Opening Block Brace Right or Left?</a></li>
- <li><a href="#Opening-Braces-Right">Opening Braces Right</a></li>
- <li><a href="#Cuddled-Else">Cuddled Else?</a></li>
- <li><a href="#Opening-Braces-Left">Opening Braces Left</a></li>
- <li><a href="#Opening-Sub-Braces">Opening Sub Braces</a></li>
- <li><a href="#Block-Brace-Vertical-Tightness">Block Brace Vertical Tightness</a></li>
- <li><a href="#Closing-Block-Brace-Indentation">Closing Block Brace Indentation</a></li>
- <li><a href="#Indentation-Style-for-Other-Containers">Indentation Style for Other Containers</a></li>
- <li><a href="#Opening-Vertical-Tightness">Opening Vertical Tightness</a></li>
- <li><a href="#Closing-Token-Placement">Closing Token Placement</a></li>
- <li><a href="#Stack-Opening-Tokens">Stack Opening Tokens</a></li>
- <li><a href="#Stack-Closing-Tokens">Stack Closing Tokens</a></li>
- <li><a href="#Define-Horizontal-Tightness">Define Horizontal Tightness</a></li>
- <li><a href="#Spaces-between-function-names-and-opening-parens">Spaces between function names and opening parens</a></li>
- <li><a href="#Spaces-between-Perl-keywords-and-parens">Spaces between Perl keywords and parens</a></li>
- <li><a href="#Statement-Termination-Semicolon-Spaces">Statement Termination Semicolon Spaces</a></li>
- <li><a href="#For-Loop-Semicolon-Spaces">For Loop Semicolon Spaces</a></li>
- <li><a href="#Block-Comment-Indentation">Block Comment Indentation</a></li>
- <li><a href="#Outdenting-Long-Quotes">Outdenting Long Quotes</a></li>
- <li><a href="#Many-Other-Parameters">Many Other Parameters</a></li>
- <li><a href="#Example-.perltidyrc-files">Example .perltidyrc files</a></li>
- <li><a href="#Tidyview">Tidyview</a></li>
- <li><a href="#Additional-Information">Additional Information</a></li>
- </ul>
- </li>
-</ul>
-
-<h1 id="Perltidy-Style-Key">Perltidy Style Key</h1>
-
-<p>When perltidy was first developed, the main parameter choices were the number of indentation spaces and if the user liked cuddled else's. As the number of users has grown so has the number of parameters. Now there are so many that it can be difficult for a new user to find a good initial set. This document is one attempt to help with this problem, and some other suggestions are given at the end.</p>
-
-<p>Use this document to methodically find a starting set of perltidy parameters to approximate your style. We will be working on just one aspect of formatting at a time. Just read each question and select the best answer. Enter your parameters in a file named <i>.perltidyrc</i> (examples are listed at the end). Then move it to one of the places where perltidy will find it. You can run perltidy with the parameter <b>-dpro</b> to see where these places are for your system.</p>
-
-<h2 id="Before-You-Start">Before You Start</h2>
-
-<p>Before you begin, experiment using just <code>perltidy filename.pl</code> on some of your files. From the results (which you will find in files with a <i>.tdy</i> extension), you will get a sense of what formatting changes, if any, you'd like to make. If the default formatting is acceptable, you do not need a <i>.perltidyrc</i> file.</p>
-
-<h2 id="Use-as-Filter">Use as Filter?</h2>
-
-<p>Do you almost always want to run perltidy as a standard filter on just one input file? If yes, use <b>-st</b> and <b>-se</b>.</p>
-
-<h2 id="Line-Length-Setting">Line Length Setting</h2>
-
-<p>Perltidy will set line breaks to prevent lines from exceeding the maximum line length.</p>
-
-<p>Do you want the maximum line length to be 80 columns? If no, use <b>-l=n</b>, where <b>n</b> is the number of columns you prefer.</p>
-
-<h2 id="Indentation-in-Code-Blocks">Indentation in Code Blocks</h2>
-
-<p>In the block below, the variable <code>$anchor</code> is one indentation level deep and is indented by 4 spaces as shown here:</p>
-
-<pre><code> if ( $flag eq "a" ) {
- $anchor = $header;
- } </code></pre>
-
-<p>If you want to change this to be a different number <b>n</b> of spaces per indentation level, use <b>-i=n</b>.</p>
-
-<h2 id="Continuation-Indentation">Continuation Indentation</h2>
-
-<p>Look at the statement beginning with <code>$anchor</code>:</p>
-
-<pre><code> if ( $flag eq "a" ) {
- $anchor =
- substr( $header, 0, 6 )
- . substr( $char_list, $place_1, 1 )
- . substr( $char_list, $place_2, 1 );
- }</code></pre>
-
-<p>The statement is too long for the line length (80 characters by default), so it has been broken into 4 lines. The second and later lines have some extra "continuation indentation" to help make the start of the statement easy to find. The default number of extra spaces is 2. If you prefer a number n different from 2, you may specify this with <b>-ci=n</b>. It is probably best if it does not exceed the value of the primary indentation.</p>
-
-<h2 id="Tabs">Tabs</h2>
-
-<p>The default, and recommendation, is to represent leading whitespace with actual space characters. However, if you prefer to entab leading whitespace with one tab character for each <b>n</b> spaces, use <b>-et=n</b>. Typically, <b>n</b> would be 8.</p>
-
-<h2 id="Opening-Block-Brace-Right-or-Left">Opening Block Brace Right or Left?</h2>
-
-<p>Opening and closing curly braces, parentheses, and square brackets are divided into two separate categories and controlled separately in most cases. The two categories are (1) code block curly braces, which contain perl code, and (2) everything else. Basically, a code block brace is one which could contain semicolon-terminated lines of perl code. We will first work on the scheme for code block curly braces.</p>
-
-<p>Decide which of the following opening brace styles you prefer for most blocks of code (with the possible exception of a <b>sub block brace</b> which will be covered later):</p>
-
-<p>If you like opening braces on the right, like this, go to <a href="#Opening-Braces-Right">"Opening Braces Right"</a>.</p>
-
-<pre><code> if ( $flag eq "h" ) {
- $headers = 0;
- } </code></pre>
-
-<p>If you like opening braces on the left, like this, go to <a href="#Opening-Braces-Left">"Opening Braces Left"</a>.</p>
-
-<pre><code> if ( $flag eq "h" )
- {
- $headers = 0;
- }</code></pre>
-
-<h2 id="Opening-Braces-Right">Opening Braces Right</h2>
-
-<p>In a multi-line <b>if</b> test expression, the default is to place the opening brace on the left, like this:</p>
-
-<pre><code> if ( $bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4 )
- {
- big_waste_of_time();
- }</code></pre>
-
-<p>This helps to visually separate the block contents from the test expression.</p>
-
-<p>An alternative is to keep the brace on the right even for multiple-line test expressions, like this:</p>
-
-<pre><code> if ( $bigwasteofspace1 && $bigwasteofspace2
- || $bigwasteofspace3 && $bigwasteofspace4 ) {
- big_waste_of_time();
- }</code></pre>
-
-<p>If you prefer this alternative, use <b>-bar</b>.</p>
-
-<h2 id="Cuddled-Else">Cuddled Else?</h2>
-
-<p>Do you prefer this <b>Cuddled Else</b> style</p>
-
-<pre><code> if ( $flag eq "h" ) {
- $headers = 0;
- } elsif ( $flag eq "f" ) {
- $sectiontype = 3;
- } else {
- print "invalid option: " . substr( $arg, $i, 1 ) . "\n";
- dohelp();
- }</code></pre>
-
-<p>instead of this default style?</p>
-
-<pre><code> if ( $flag eq "h" ) {
- $headers = 0;
- }
- elsif ( $flag eq "f" ) {
- $sectiontype = 3;
- }
- else {
- print "invalid option: " . substr( $arg, $i, 1 ) . "\n";
- dohelp();
- }</code></pre>
-
-<p>If yes, you should use <b>-ce</b>. Now skip ahead to <a href="#Opening-Sub-Braces">"Opening Sub Braces"</a>.</p>
-
-<h2 id="Opening-Braces-Left">Opening Braces Left</h2>
-
-<p>Use <b>-bl</b> if you prefer this style:</p>
-
-<pre><code> if ( $flag eq "h" )
- {
- $headers = 0;
- }</code></pre>
-
-<p>Use <b>-bli</b> if you prefer this indented-brace style:</p>
-
-<pre><code> if ( $flag eq "h" )
- {
- $headers = 0;
- }</code></pre>
-
-<p>The number of spaces of extra indentation will be the value specified for continuation indentation with the <b>-ci=n</b> parameter (2 by default).</p>
-
-<h2 id="Opening-Sub-Braces">Opening Sub Braces</h2>
-
-<p>By default, the opening brace of a sub block will be treated the same as other code blocks. If this is okay, skip ahead to <a href="#Block-Brace-Vertical-Tightness">"Block Brace Vertical Tightness"</a>.</p>
-
-<p>If you prefer an opening sub brace to be on a new line, like this:</p>
-
-<pre><code> sub message
- {
- # -sbl
- }</code></pre>
-
-<p>use <b>-sbl</b>. If you prefer the sub brace on the right like this</p>
-
-<pre><code> sub message {
-
- # -nsbl
- }</code></pre>
-
-<p>use <b>-nsbl</b>.</p>
-
-<p>If you wish to give this opening sub brace some indentation you can do that with the parameters <b>-bli</b> and <b>-blil</b> which are described in the manual.</p>
-
-<h2 id="Block-Brace-Vertical-Tightness">Block Brace Vertical Tightness</h2>
-
-<p>If you chose to put opening block braces of all types to the right, skip ahead to <a href="#Closing-Block-Brace-Indentation">"Closing Block Brace Indentation"</a>.</p>
-
-<p>If you chose to put braces of any type on the left, the default is to leave the opening brace on a line by itself, like this (shown for <b>-bli</b>, but also true for <b>-bl</b>):</p>
-
-<pre><code> if ( $flag eq "h" )
- {
- $headers = 0;
- }</code></pre>
-
-<p>But you may also use this more compressed style if you wish:</p>
-
-<pre><code> if ( $flag eq "h" )
- { $headers = 0;
- }</code></pre>
-
-<p>If you do not prefer this more compressed form, go to <a href="#Opening-Sub-Braces">"Opening Sub Braces"</a>.</p>
-
-<p>Otherwise use parameter <b>-bbvt=n</b>, where n=1 or n=2. To decide, look at this snippet:</p>
-
-<pre><code> # -bli -bbvt=1
- sub _directives
- {
- {
- 'ENDIF' => \&_endif,
- 'IF' => \&_if,
- };
- }
-
- # -bli -bbvt=2
- sub _directives
- { {
- 'ENDIF' => \&_endif,
- 'IF' => \&_if,
- };
- }</code></pre>
-
-<p>The difference is that <b>-bbvt=1</b> breaks after an opening brace if the next line is unbalanced, whereas <b>-bbvt=2</b> never breaks.</p>
-
-<p>If you were expecting the 'ENDIF' word to move up vertically here, note that the second opening brace in the above example is not a code block brace (it is a hash brace), so the <b>-bbvt</b> does not apply to it (another parameter will).</p>
-
-<h2 id="Closing-Block-Brace-Indentation">Closing Block Brace Indentation</h2>
-
-<p>The default is to place closing braces at the same indentation as the opening keyword or brace of that code block, as shown here:</p>
-
-<pre><code> if ($task) {
- yyy();
- } # default</code></pre>
-
-<p>If you chose the <b>-bli</b> style, however, the default closing braces will be indented one continuation indentation like the opening brace:</p>
-
-<pre><code> if ($task)
- {
- yyy();
- } # -bli</code></pre>
-
-<p>If you prefer to give closing block braces one full level of indentation, independently of how the opening brace is treated, for example like this:</p>
-
-<pre><code> if ($task) {
- yyy();
- } # -icb</code></pre>
-
-<p>use <b>-icb</b>.</p>
-
-<p>This completes the definition of the placement of code block braces.</p>
-
-<h2 id="Indentation-Style-for-Other-Containers">Indentation Style for Other Containers</h2>
-
-<p>You have a choice of two basic indentation schemes for non-block containers. The default is to use a fixed number of spaces per indentation level (the same number of spaces used for code blocks, which is 4 by default). Here is an example of the default:</p>
-
-<pre><code> $dbh = DBI->connect(
- undef, undef, undef,
- {
- PrintError => 0,
- RaiseError => 1
- }
- );</code></pre>
-
-<p>In this default indentation scheme, a simple formula is used to find the indentation of every line. Notice how the first 'undef' is indented 4 spaces (one level) to the right, and how 'PrintError' is indented 4 more speces (one more level) to the right.</p>
-
-<p>The alternate is to let the location of the opening paren (or square bracket, or curly brace) define the indentation, like this:</p>
-
-<pre><code> $dbh = DBI->connect(
- undef, undef, undef,
- {
- PrintError => 0,
- RaiseError => 1
- }
- );</code></pre>
-
-<p>The first scheme is completely robust. The second scheme often looks a little nicer, but be aware that deeply nested structures it can be spoiled if the line length limit is exceeded. Also, if there are comments or blank lines within a complex structure perltidy will temporarily fall back on the default indentation scheme. You may want to try both on large sections of code to see which works best.</p>
-
-<p>If you prefer the first (default) scheme, no parameter is needed.</p>
-
-<p>If you prefer the latter scheme, use <b>-lp</b>.</p>
-
-<h2 id="Opening-Vertical-Tightness">Opening Vertical Tightness</h2>
-
-<p>The information in this section applies mainly to the <b>-lp</b> style but it also applies in some cases to the default style. It will be illustrated for the <b>-lp</b> indentation style.</p>
-
-<p>The default <b>-lp</b> indentation style ends a line at the opening tokens, like this:</p>
-
-<pre><code> $dbh = DBI->connect(
- undef, undef, undef,
- {
- PrintError => 0,
- RaiseError => 1
- }
- );</code></pre>
-
-<p>Here is a tighter alternative, which does not end a line with the opening tokens:</p>
-
-<pre><code> $dbh = DBI->connect( undef, undef, undef,
- { PrintError => 0,
- RaiseError => 1
- }
- );</code></pre>
-
-<p>The difference is that the lines have been compressed vertically without any changes to the indentation. This can almost always be done with the <b>-lp</b> indentation style, but only in limited cases for the default indentation style.</p>
-
-<p>If you prefer the default, skip ahead to <a href="#Closing-Token-Placement">"Closing Token Placement"</a>.</p>
-
-<p>Otherwise, use <b>-vt=n</b>, where <b>n</b> should be either 1 or 2. To help decide, observe the first three opening parens in the following snippet and choose the value of n you prefer. Here it is with <b>-lp -vt=1</b>:</p>
-
-<pre><code> if (
- !defined(
- start_slip( $DEVICE, $PHONE, $ACCOUNT, $PASSWORD,
- $LOCAL, $REMOTE, $NETMASK, $MTU
- )
- )
- && $continuation_flag
- )
- {
- do_something_about_it();
- }</code></pre>
-
-<p>And here it is again formatted with <b>-lp -vt=2</b>:</p>
-
-<pre><code> if ( !defined( start_slip( $DEVICE, $PHONE, $ACCOUNT, $PASSWORD,
- $LOCAL, $REMOTE, $NETMASK, $MTU
- )
- )
- && $continuation_flag
- )
- {
- do_something_about_it();
- }</code></pre>
-
-<p>The <b>-vt=1</b> style tries to display the structure by preventing more than one step in indentation per line. In this example, the first two opening parens were not followed by balanced lines, so <b>-vt=1</b> broke after them.</p>
-
-<p>The <b>-vt=2</b> style does not limit itself to a single indentation step per line.</p>
-
-<p>Note that in the above example the function 'do_sumething_about_it' started on a new line. This is because it follows an opening code block brace and is governed by the flag previously set in <a href="#Block-Brace-Vertical-Tightness">"Block Brace Vertical Tightness"</a>.</p>
-
-<h2 id="Closing-Token-Placement">Closing Token Placement</h2>
-
-<p>You have several options for dealing with the terminal closing tokens of non-blocks. In the following examples, a closing parenthesis is shown, but these parameters apply to closing square brackets and non-block curly braces as well.</p>
-
-<p>The default behavior for parenthesized relatively large lists is to place the closing paren on a separate new line. The flag <b>-cti=n</b> controls the amount of indentation of such a closing paren.</p>
-
-<p>The default, <b>-cti=0</b>, for a line beginning with a closing paren, is to use the indentation defined by the next (lower) indentation level. This works well for the default indentation scheme:</p>
-
-<pre><code> # perltidy
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<p>but it may not look very good with the <b>-lp</b> indentation scheme:</p>
-
-<pre><code> # perltidy -lp
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<p>An alternative which works well with <b>-lp</b> indentation is <b>-cti=1</b>, which aligns the closing paren vertically with its opening paren, if possible:</p>
-
-<pre><code> # perltidy -lp -cti=1
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<p>Another alternative, <b>-cti=3</b>, indents a line with leading closing paren one full indentation level:</p>
-
-<pre><code> # perltidy -lp -cti=3
- @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
- );</code></pre>
-
-<p>If you prefer the closing paren on a separate line like this, note the value of <b>-cti=n</b> that you prefer and skip ahead to <a href="#Define-Horizontal-Tightness">"Define Horizontal Tightness"</a>.</p>
-
-<p>Finally, the question of paren indentation can be avoided by placing it at the end of the previous line, like this:</p>
-
-<pre><code> @month_of_year = (
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );</code></pre>
-
-<p>Perltidy will automatically do this to save space for very short lists but not for longer lists.</p>
-
-<p>Use <b>-vtc=n</b> if you prefer to usually do this, where <b>n</b> is either 1 or 2. To determine <b>n</b>, we have to look at something more complex. Observe the behavior of the closing tokens in the following snippet:</p>
-
-<p>Here is <b>-lp -vtc=1</b>:</p>
-
-<pre><code> $srec->{'ACTION'} = [
- $self->read_value(
- $lookup->{'VFMT'},
- $loc, $lookup, $fh
- ),
- $self->read_value(
- $lookup->{'VFMT2'},
- $loc, $lookup, $fh
- ) ];</code></pre>
-
-<p>Here is <b>-lp -vtc=2</b>:</p>
-
-<pre><code> $srec->{'ACTION'} = [
- $self->read_value(
- $lookup->{'VFMT'},
- $loc, $lookup, $fh ),
- $self->read_value(
- $lookup->{'VFMT2'},
- $loc, $lookup, $fh ) ];</code></pre>
-
-<p>Choose the one that you prefer. The difference is that <b>-vtc=1</b> leaves closing tokens at the start of a line within a list, which can assist in keeping hierarchical lists readable. The <b>-vtc=2</b> style always tries to move closing tokens to the end of a line.</p>
-
-<p>If you choose <b>-vtc=1</b>, you may also want to specify a value of <b>-cti=n</b> (previous section) to handle cases where a line begins with a closing paren.</p>
-
-<h2 id="Stack-Opening-Tokens">Stack Opening Tokens</h2>
-
-<p>In the following snippet the opening hash brace has been placed alone on a new line.</p>
-
-<pre><code> $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );</code></pre>
-
-<p>If you prefer to avoid isolated opening tokens by "stacking" them together with other opening tokens like this:</p>
-
-<pre><code> $opt_c = Text::CSV_XS->new( {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );</code></pre>
-
-<p>use <b>-sot</b>.</p>
-
-<h2 id="Stack-Closing-Tokens">Stack Closing Tokens</h2>
-
-<p>Likewise, in the same snippet the default formatting leaves the closing paren on a line by itself here:</p>
-
-<pre><code> $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- }
- );</code></pre>
-
-<p>If you would like to avoid leaving isolated closing tokens by stacking them with other closing tokens, like this:</p>
-
-<pre><code> $opt_c = Text::CSV_XS->new(
- {
- binary => 1,
- sep_char => $opt_c,
- always_quote => 1,
- } );</code></pre>
-
-<p>use <b>-sct</b>.</p>
-
-<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 "hiding" 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 multiple closing tokens together, but it does not try to hide them.</p>
-
-<p>The manual shows how all of these vertical tightness controls may be applied independently to each type of non-block opening and opening token.</p>
-
-<h2 id="Define-Horizontal-Tightness">Define Horizontal Tightness</h2>
-
-<p>Horizontal tightness parameters define how much space is included within a set of container tokens.</p>
-
-<p>For parentheses, decide which of the following values of <b>-pt=n</b> you prefer:</p>
-
-<pre><code> if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
- if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
- if ((my $len_tab = length($tabstr)) > 0) { # -pt=2</code></pre>
-
-<p>For n=0, space is always used, and for n=2, space is never used. For the default n=1, space is used if the parentheses contain more than one token.</p>
-
-<p>For square brackets, decide which of the following values of <b>-sbt=n</b> you prefer:</p>
-
-<pre><code> $width = $col[ $j + $k ] - $col[ $j ]; # -sbt=0
- $width = $col[ $j + $k ] - $col[$j]; # -sbt=1 (default)
- $width = $col[$j + $k] - $col[$j]; # -sbt=2 </code></pre>
-
-<p>For curly braces, decide which of the following values of <b>-bt=n</b> you prefer:</p>
-
-<pre><code> $obj->{ $parsed_sql->{ 'table' }[0] }; # -bt=0
- $obj->{ $parsed_sql->{'table'}[0] }; # -bt=1 (default)
- $obj->{$parsed_sql->{'table'}[0]}; # -bt=2</code></pre>
-
-<p>For code block curly braces, decide which of the following values of <b>-bbt=n</b> you prefer:</p>
-
-<pre><code> %bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.'; # -bbt=0 (default)
- %bf = map { $_ => -M $_ } grep {/\.deb$/} dirents '.'; # -bbt=1
- %bf = map {$_ => -M $_} grep {/\.deb$/} dirents '.'; # -bbt=2</code></pre>
-
-<h2 id="Spaces-between-function-names-and-opening-parens">Spaces between function names and opening parens</h2>
-
-<p>The default is not to place a space after a function call:</p>
-
-<pre><code> myfunc( $a, $b, $c ); # default </code></pre>
-
-<p>If you prefer a space:</p>
-
-<pre><code> myfunc ( $a, $b, $c ); # -sfp</code></pre>
-
-<p>use <b>-sfp</b>.</p>
-
-<h2 id="Spaces-between-Perl-keywords-and-parens">Spaces between Perl keywords and parens</h2>
-
-<p>The default is to place a space between only these keywords and an opening paren:</p>
-
-<pre><code> my local our and or eq ne if else elsif until unless
- while for foreach return switch case given when</code></pre>
-
-<p>but no others. For example, the default is:</p>
-
-<pre><code> $aa = pop(@bb);</code></pre>
-
-<p>If you want a space between all Perl keywords and an opening paren,</p>
-
-<pre><code> $aa = pop (@bb);</code></pre>
-
-<p>use <b>-skp</b>. For detailed control of individual keywords, see the manual.</p>
-
-<h2 id="Statement-Termination-Semicolon-Spaces">Statement Termination Semicolon Spaces</h2>
-
-<p>The default is not to put a space before a statement termination semicolon, like this:</p>
-
-<pre><code> $i = 1;</code></pre>
-
-<p>If you prefer a space, like this:</p>
-
-<pre><code> $i = 1 ; </code></pre>
-
-<p>enter <b>-sts</b>.</p>
-
-<h2 id="For-Loop-Semicolon-Spaces">For Loop Semicolon Spaces</h2>
-
-<p>The default is to place a space before a semicolon in a for statement, like this:</p>
-
-<pre><code> for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) { # -sfs (default)</code></pre>
-
-<p>If you prefer no such space, like this:</p>
-
-<pre><code> for ( @a = @$ap, $u = shift @a; @a; $u = $v ) { # -nsfs</code></pre>
-
-<p>enter <b>-nsfs</b>.</p>
-
-<h2 id="Block-Comment-Indentation">Block Comment Indentation</h2>
-
-<p>Block comments are comments which occupy a full line, as opposed to side comments. The default is to indent block comments with the same indentation as the code block that contains them (even though this will allow long comments to exceed the maximum line length).</p>
-
-<p>If you would like block comments indented except when this would cause the maximum line length to be exceeded, use <b>-olc</b>. This will cause a group of consecutive block comments to be outdented by the amount needed to prevent any one from exceeding the maximum line length.</p>
-
-<p>If you never want block comments indented, use <b>-nibc</b>.</p>
-
-<p>If block comments may only be indented if they have some space characters before the leading <code>#</code> character in the input file, use <b>-isbc</b>.</p>
-
-<p>The manual shows many other options for controlling comments.</p>
-
-<h2 id="Outdenting-Long-Quotes">Outdenting Long Quotes</h2>
-
-<p>Long quoted strings may exceed the specified line length limit. The default, when this happens, is to outdent them to the first column. Here is an example of an outdented long quote:</p>
-
-<pre><code> if ($source_stream) {
- if ( @ARGV > 0 ) {
- die
- "You may not specify any filenames when a source array is given\n";
- }
- }</code></pre>
-
-<p>The effect is not too different from using a here document to represent the quote. If you prefer to leave the quote indented, like this:</p>
-
-<pre><code> if ($source_stream) {
- if ( @ARGV > 0 ) {
- die
- "You may not specify any filenames when a source array is given\n";
- }
- }</code></pre>
-
-<p>use <b>-nolq</b>.</p>
-
-<h2 id="Many-Other-Parameters">Many Other Parameters</h2>
-
-<p>This document has only covered the most popular parameters. The manual contains many more and should be consulted if you did not find what you need here.</p>
-
-<h2 id="Example-.perltidyrc-files">Example <i>.perltidyrc</i> files</h2>
-
-<p>Now gather together all of the parameters you prefer and enter them in a file called <i>.perltidyrc</i>.</p>
-
-<p>Here are some example <i>.perltidyrc</i> files and the corresponding style.</p>
-
-<p>Here is a little test snippet, shown the way it would appear with the default style.</p>
-
-<pre><code> for (@methods) {
- push (
- @results,
- {
- name => $_->name,
- help => $_->help,
- }
- );
- }</code></pre>
-
-<p>You do not need a <i>.perltidyrc</i> file for this style.</p>
-
-<p>Here is the same snippet</p>
-
-<pre><code> for (@methods)
- {
- push(@results,
- { name => $_->name,
- help => $_->help,
- }
- );
- }</code></pre>
-
-<p>for a <i>.perltidyrc</i> file containing these parameters:</p>
-
-<pre><code> -bl
- -lp
- -cti=1
- -vt=1
- -pt=2</code></pre>
-
-<p>You do not need to place just one parameter per line, but this may be convenient for long lists. You may then hide any parameter by placing a <code>#</code> symbol before it.</p>
-
-<p>And here is the snippet</p>
-
-<pre><code> for (@methods) {
- push ( @results,
- { name => $_->name,
- help => $_->help,
- } );
- }</code></pre>
-
-<p>for a <i>.perltidyrc</i> file containing these parameters:</p>
-
-<pre><code> -lp
- -vt=1
- -vtc=1</code></pre>
-
-<h2 id="Tidyview">Tidyview</h2>
-
-<p>There is a graphical program called <b>tidyview</b> which you can use to read a preliminary <i>.perltidyrc</i> file, make trial adjustments and immediately see their effect on a test file, and then write a new <i>.perltidyrc</i>. You can download a copy at</p>
-
-<p>http://sourceforge.net/projects/tidyview</p>
-
-<h2 id="Additional-Information">Additional Information</h2>
-
-<p>This document has covered the main parameters. Many more parameters are available for special purposes and for fine-tuning a style. For complete information see the perltidy manual http://perltidy.sourceforge.net/perltidy.html</p>
-
-<p>For an introduction to using perltidy, see the tutorial http://perltidy.sourceforge.net/tutorial.html</p>
-
-<p>Suggestions for improving this document are welcome and may be sent to perltidy at users.sourceforge.net</p>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# Perltidy Style Key
+
+When perltidy was first developed, the main parameter choices were the number
+of indentation spaces and if the user liked cuddled else's. As the number of
+users has grown so has the number of parameters. Now there are so many that it
+can be difficult for a new user to find a good initial set. This document is
+one attempt to help with this problem, and some other suggestions are given at
+the end.
+
+Use this document to methodically find a starting set of perltidy parameters to
+approximate your style. We will be working on just one aspect of formatting at
+a time. Just read each question and select the best answer. Enter your
+parameters in a file named `.perltidyrc` (examples are listed at the end).
+Then move it to one of the places where perltidy will find it. You can run
+perltidy with the parameter **-dpro** to see where these places are for your
+system.
+
+## Before You Start
+
+Before you begin, experiment using just `perltidy filename.pl` on some
+of your files. From the results (which you will find in files with a
+`.tdy` extension), you will get a sense of what formatting changes, if
+any, you'd like to make. If the default formatting is acceptable, you
+do not need a `.perltidyrc` file.
+
+## Use as Filter?
+
+Do you almost always want to run perltidy as a standard filter on just
+one input file? If yes, use **-st** and **-se**.
+
+## Line Length Setting
+
+Perltidy will set line breaks to prevent lines from exceeding the
+maximum line length.
+
+Do you want the maximum line length to be 80 columns? If no, use
+**-l=n**, where **n** is the number of columns you prefer.
+
+## Indentation in Code Blocks
+
+In the block below, the variable `$anchor` is one indentation level deep
+and is indented by 4 spaces as shown here:
+
+ if ( $flag eq "a" ) {
+ $anchor = $header;
+ }
+
+If you want to change this to be a different number **n** of spaces
+per indentation level, use **-i=n**.
+
+## Continuation Indentation
+
+Look at the statement beginning with `$anchor`:
+
+ if ( $flag eq "a" ) {
+ $anchor =
+ substr( $header, 0, 6 )
+ . substr( $char_list, $place_1, 1 )
+ . substr( $char_list, $place_2, 1 );
+ }
+
+The statement is too long for the line length (80 characters by default), so it
+has been broken into 4 lines. The second and later lines have some extra
+"continuation indentation" to help make the start of the statement easy to
+find. The default number of extra spaces is 2. If you prefer a number n
+different from 2, you may specify this with **-ci=n**. It is probably best if
+it does not exceed the value of the primary indentation.
+
+## Tabs
+
+The default, and recommendation, is to represent leading whitespace
+with actual space characters. However, if you prefer to entab
+leading whitespace with one tab character for each **n** spaces,
+use **-et=n**. Typically, **n** would be 8.
+
+## Opening Block Brace Right or Left?
+
+Opening and closing curly braces, parentheses, and square brackets are divided
+into two separate categories and controlled separately in most cases. The two
+categories are (1) code block curly braces, which contain perl code, and (2)
+everything else. Basically, a code block brace is one which could contain
+semicolon-terminated lines of perl code. We will first work on the scheme for
+code block curly braces.
+
+Decide which of the following opening brace styles you prefer for most blocks
+of code (with the possible exception of a **sub block brace** which will
+be covered later):
+
+If you like opening braces on the right, like this, go to
+["Opening Braces Right"](#opening-braces-right).
+
+ if ( $flag eq "h" ) {
+ $headers = 0;
+ }
+
+If you like opening braces on the left, like this, go to
+["Opening Braces Left"](#opening-braces-left).
+
+ if ( $flag eq "h" )
+ {
+ $headers = 0;
+ }
+
+## Opening Braces Right
+
+In a multi-line **if** test expression, the default is to place
+the opening brace on the left, like this:
+
+ if ( $bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4 )
+ {
+ big_waste_of_time();
+ }
+
+This helps to visually separate the block contents from the test
+expression.
+
+An alternative is to keep the brace on the right even for
+multiple-line test expressions, like this:
+
+ if ( $bigwasteofspace1 && $bigwasteofspace2
+ || $bigwasteofspace3 && $bigwasteofspace4 ) {
+ big_waste_of_time();
+ }
+
+If you prefer this alternative, use **-bar**.
+
+## Cuddled Else?
+
+Do you prefer this **Cuddled Else** style
+
+ if ( $flag eq "h" ) {
+ $headers = 0;
+ } elsif ( $flag eq "f" ) {
+ $sectiontype = 3;
+ } else {
+ print "invalid option: " . substr( $arg, $i, 1 ) . "\n";
+ dohelp();
+ }
+
+instead of this default style?
+
+ if ( $flag eq "h" ) {
+ $headers = 0;
+ }
+ elsif ( $flag eq "f" ) {
+ $sectiontype = 3;
+ }
+ else {
+ print "invalid option: " . substr( $arg, $i, 1 ) . "\n";
+ dohelp();
+ }
+
+If yes, you should use **-ce**.
+Now skip ahead to ["Opening Sub Braces"](#opening-sub-braces).
+
+## Opening Braces Left
+
+Use **-bl** if you prefer this style:
+
+ if ( $flag eq "h" )
+ {
+ $headers = 0;
+ }
+
+Use **-bli** if you prefer this indented-brace style:
+
+ if ( $flag eq "h" )
+ {
+ $headers = 0;
+ }
+
+The number of spaces of extra indentation will be the value specified
+for continuation indentation with the **-ci=n** parameter (2 by default).
+
+## Opening Sub Braces
+
+By default, the opening brace of a sub block will be treated
+the same as other code blocks. If this is okay, skip ahead
+to ["Block Brace Vertical Tightness"](#block-brace-vertical-tightness).
+
+If you prefer an opening sub brace to be on a new line,
+like this:
+
+ sub message
+ {
+ # -sbl
+ }
+
+use **-sbl**. If you prefer the sub brace on the right like this
+
+ sub message {
+
+ # -nsbl
+ }
+
+use **-nsbl**.
+
+If you wish to give this opening sub brace some indentation you can do
+that with the parameters **-bli** and **-blil** which are described in the
+manual.
+
+## Block Brace Vertical Tightness
+
+If you chose to put opening block braces of all types to the right, skip
+ahead to ["Closing Block Brace Indentation"](#closing-block-brace-indentation).
+
+If you chose to put braces of any type on the left, the default is to leave the
+opening brace on a line by itself, like this (shown for **-bli**, but also true
+for **-bl**):
+
+ if ( $flag eq "h" )
+ {
+ $headers = 0;
+ }
+
+But you may also use this more compressed style if you wish:
+
+ if ( $flag eq "h" )
+ { $headers = 0;
+ }
+
+If you do not prefer this more compressed form, go to
+["Opening Sub Braces"](#opening-sub-braces).
+
+Otherwise use parameter **-bbvt=n**, where n=1 or n=2. To decide,
+look at this snippet:
+
+ # -bli -bbvt=1
+ sub _directives
+ {
+ {
+ 'ENDIF' => \&_endif,
+ 'IF' => \&_if,
+ };
+ }
+
+ # -bli -bbvt=2
+ sub _directives
+ { {
+ 'ENDIF' => \&_endif,
+ 'IF' => \&_if,
+ };
+ }
+
+The difference is that **-bbvt=1** breaks after an opening brace if
+the next line is unbalanced, whereas **-bbvt=2** never breaks.
+
+If you were expecting the 'ENDIF' word to move up vertically here, note that
+the second opening brace in the above example is not a code block brace (it is
+a hash brace), so the **-bbvt** does not apply to it (another parameter will).
+
+## Closing Block Brace Indentation
+
+The default is to place closing braces at the same indentation as the
+opening keyword or brace of that code block, as shown here:
+
+ if ($task) {
+ yyy();
+ } # default
+
+If you chose the **-bli** style, however, the default closing braces will be
+indented one continuation indentation like the opening brace:
+
+ if ($task)
+ {
+ yyy();
+ } # -bli
+
+If you prefer to give closing block braces one full level of
+indentation, independently of how the opening brace is treated,
+for example like this:
+
+ if ($task) {
+ yyy();
+ } # -icb
+
+use **-icb**.
+
+This completes the definition of the placement of code block braces.
+
+## Indentation Style for Other Containers
+
+You have a choice of two basic indentation schemes for non-block containers.
+The default is to use a fixed number of spaces per indentation level (the same
+number of spaces used for code blocks, which is 4 by default). Here is an
+example of the default:
+
+ $dbh = DBI->connect(
+ undef, undef, undef,
+ {
+ PrintError => 0,
+ RaiseError => 1
+ }
+ );
+
+In this default indentation scheme, a simple formula is used to find the
+indentation of every line. Notice how the first 'undef' is indented 4
+spaces (one level) to the right, and how 'PrintError' is indented 4 more
+speces (one more level) to the right.
+
+The alternate is to let the location of the opening paren (or square
+bracket, or curly brace) define the indentation, like this:
+
+ $dbh = DBI->connect(
+ undef, undef, undef,
+ {
+ PrintError => 0,
+ RaiseError => 1
+ }
+ );
+
+The first scheme is completely robust. The second scheme often looks a little
+nicer, but be aware that deeply nested structures it can be spoiled if the line
+length limit is exceeded. Also, if there are comments or blank lines within a
+complex structure perltidy will temporarily fall back on the default
+indentation scheme. You may want to try both on large sections of code to see
+which works best.
+
+If you prefer the first (default) scheme, no parameter is needed.
+
+If you prefer the latter scheme, use **-lp**.
+
+## Opening Vertical Tightness
+
+The information in this section applies mainly to the **-lp**
+style but it also applies in some cases to the default style.
+It will be illustrated for the **-lp** indentation style.
+
+The default **-lp** indentation style ends a line at the
+opening tokens, like this:
+
+ $dbh = DBI->connect(
+ undef, undef, undef,
+ {
+ PrintError => 0,
+ RaiseError => 1
+ }
+ );
+
+Here is a tighter alternative, which does not end a line
+with the opening tokens:
+
+ $dbh = DBI->connect( undef, undef, undef,
+ { PrintError => 0,
+ RaiseError => 1
+ }
+ );
+
+The difference is that the lines have been compressed vertically without
+any changes to the indentation. This can almost always be done with the
+**-lp** indentation style, but only in limited cases for the default
+indentation style.
+
+If you prefer the default, skip ahead to ["Closing Token Placement"](#closing-token-placement).
+
+Otherwise, use **-vt=n**, where **n** should be either 1 or 2. To help
+decide, observe the first three opening parens in the following snippet
+and choose the value of n you prefer. Here it is with **-lp -vt=1**:
+
+ if (
+ !defined(
+ start_slip( $DEVICE, $PHONE, $ACCOUNT, $PASSWORD,
+ $LOCAL, $REMOTE, $NETMASK, $MTU
+ )
+ )
+ && $continuation_flag
+ )
+ {
+ do_something_about_it();
+ }
+
+And here it is again formatted with **-lp -vt=2**:
+
+ if ( !defined( start_slip( $DEVICE, $PHONE, $ACCOUNT, $PASSWORD,
+ $LOCAL, $REMOTE, $NETMASK, $MTU
+ )
+ )
+ && $continuation_flag
+ )
+ {
+ do_something_about_it();
+ }
+
+The **-vt=1** style tries to display the structure by preventing more
+than one step in indentation per line. In this example, the first two
+opening parens were not followed by balanced lines, so **-vt=1** broke
+after them.
+
+The **-vt=2** style does not limit itself to a single indentation step
+per line.
+
+Note that in the above example the function 'do\_sumething\_about\_it'
+started on a new line. This is because it follows an opening code
+block brace and is governed by the flag previously set in
+["Block Brace Vertical Tightness"](#block-brace-vertical-tightness).
+
+## Closing Token Placement
+
+You have several options for dealing with the terminal closing tokens of
+non-blocks. In the following examples, a closing parenthesis is shown, but
+these parameters apply to closing square brackets and non-block curly braces as
+well.
+
+The default behavior for parenthesized relatively large lists is to place the
+closing paren on a separate new line. The flag **-cti=n** controls the amount
+of indentation of such a closing paren.
+
+The default, **-cti=0**, for a line beginning with a closing paren, is to use
+the indentation defined by the next (lower) indentation level. This works
+well for the default indentation scheme:
+
+ # perltidy
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+but it may not look very good with the **-lp** indentation scheme:
+
+ # perltidy -lp
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+An alternative which works well with **-lp** indentation is **-cti=1**,
+which aligns the closing paren vertically with its
+opening paren, if possible:
+
+ # perltidy -lp -cti=1
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+Another alternative, **-cti=3**, indents a line with leading closing
+paren one full indentation level:
+
+ # perltidy -lp -cti=3
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+
+If you prefer the closing paren on a separate line like this,
+note the value of **-cti=n** that you prefer and skip ahead to
+["Define Horizontal Tightness"](#define-horizontal-tightness).
+
+Finally, the question of paren indentation can be avoided by placing it
+at the end of the previous line, like this:
+
+ @month_of_year = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
+
+Perltidy will automatically do this to save space for very short lists but not
+for longer lists.
+
+Use **-vtc=n** if you prefer to usually do this, where **n** is either 1 or 2. To
+determine **n**, we have to look at something more complex. Observe the
+behavior of the closing tokens in the following snippet:
+
+Here is **-lp -vtc=1**:
+
+ $srec->{'ACTION'} = [
+ $self->read_value(
+ $lookup->{'VFMT'},
+ $loc, $lookup, $fh
+ ),
+ $self->read_value(
+ $lookup->{'VFMT2'},
+ $loc, $lookup, $fh
+ ) ];
+
+Here is **-lp -vtc=2**:
+
+ $srec->{'ACTION'} = [
+ $self->read_value(
+ $lookup->{'VFMT'},
+ $loc, $lookup, $fh ),
+ $self->read_value(
+ $lookup->{'VFMT2'},
+ $loc, $lookup, $fh ) ];
+
+Choose the one that you prefer. The difference is that **-vtc=1** leaves
+closing tokens at the start of a line within a list, which can assist in
+keeping hierarchical lists readable. The **-vtc=2** style always tries
+to move closing tokens to the end of a line.
+
+If you choose **-vtc=1**,
+you may also want to specify a value of **-cti=n** (previous section) to
+handle cases where a line begins with a closing paren.
+
+## Stack Opening Tokens
+
+In the following snippet the opening hash brace has been placed
+alone on a new line.
+
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+If you prefer to avoid isolated opening tokens by
+"stacking" them together with other opening tokens like this:
+
+ $opt_c = Text::CSV_XS->new( {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+use **-sot**.
+
+## Stack Closing Tokens
+
+Likewise, in the same snippet the default formatting leaves
+the closing paren on a line by itself here:
+
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ }
+ );
+
+If you would like to avoid leaving isolated closing tokens by
+stacking them with other closing tokens, like this:
+
+ $opt_c = Text::CSV_XS->new(
+ {
+ binary => 1,
+ sep_char => $opt_c,
+ always_quote => 1,
+ } );
+
+use **-sct**.
+
+The **-sct** flag is somewhat similar to the **-vtc** flags, and in some cases it
+can give a similar result. The difference is that the **-vtc** flags try to
+avoid lines with leading opening tokens by "hiding" them at the end of a
+previous line, whereas the **-sct** flag merely tries to reduce the number of
+lines with isolated closing tokens by stacking multiple closing tokens
+together, but it does not try to hide them.
+
+The manual shows how all of these vertical tightness controls may be applied
+independently to each type of non-block opening and opening token.
+
+## Define Horizontal Tightness
+
+Horizontal tightness parameters define how much space is included
+within a set of container tokens.
+
+For parentheses, decide which of the following values of **-pt=n**
+you prefer:
+
+ if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
+ if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
+ if ((my $len_tab = length($tabstr)) > 0) { # -pt=2
+
+For n=0, space is always used, and for n=2, space is never used. For
+the default n=1, space is used if the parentheses contain more than
+one token.
+
+For square brackets, decide which of the following values of **-sbt=n**
+you prefer:
+
+ $width = $col[ $j + $k ] - $col[ $j ]; # -sbt=0
+ $width = $col[ $j + $k ] - $col[$j]; # -sbt=1 (default)
+ $width = $col[$j + $k] - $col[$j]; # -sbt=2
+
+For curly braces, decide which of the following values of **-bt=n**
+you prefer:
+
+ $obj->{ $parsed_sql->{ 'table' }[0] }; # -bt=0
+ $obj->{ $parsed_sql->{'table'}[0] }; # -bt=1 (default)
+ $obj->{$parsed_sql->{'table'}[0]}; # -bt=2
+
+For code block curly braces, decide which of the following values of
+**-bbt=n** you prefer:
+
+ %bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.'; # -bbt=0 (default)
+ %bf = map { $_ => -M $_ } grep {/\.deb$/} dirents '.'; # -bbt=1
+ %bf = map {$_ => -M $_} grep {/\.deb$/} dirents '.'; # -bbt=2
+
+## Spaces between function names and opening parens
+
+The default is not to place a space after a function call:
+
+ myfunc( $a, $b, $c ); # default
+
+If you prefer a space:
+
+ myfunc ( $a, $b, $c ); # -sfp
+
+use **-sfp**.
+
+## Spaces between Perl keywords and parens
+
+The default is to place a space between only these keywords
+and an opening paren:
+
+ my local our and or eq ne if else elsif until unless
+ while for foreach return switch case given when
+
+but no others. For example, the default is:
+
+ $aa = pop(@bb);
+
+If you want a space between all Perl keywords and an opening paren,
+
+ $aa = pop (@bb);
+
+use **-skp**. For detailed control of individual keywords, see the manual.
+
+## Statement Termination Semicolon Spaces
+
+The default is not to put a space before a statement termination
+semicolon, like this:
+
+ $i = 1;
+
+If you prefer a space, like this:
+
+ $i = 1 ;
+
+enter **-sts**.
+
+## For Loop Semicolon Spaces
+
+The default is to place a space before a semicolon in a for statement,
+like this:
+
+ for ( @a = @$ap, $u = shift @a ; @a ; $u = $v ) { # -sfs (default)
+
+If you prefer no such space, like this:
+
+ for ( @a = @$ap, $u = shift @a; @a; $u = $v ) { # -nsfs
+
+enter **-nsfs**.
+
+## Block Comment Indentation
+
+Block comments are comments which occupy a full line, as opposed to side
+comments. The default is to indent block comments with the same
+indentation as the code block that contains them (even though this
+will allow long comments to exceed the maximum line length).
+
+If you would like block comments indented except when this would cause
+the maximum line length to be exceeded, use **-olc**. This will cause a
+group of consecutive block comments to be outdented by the amount needed
+to prevent any one from exceeding the maximum line length.
+
+If you never want block comments indented, use **-nibc**.
+
+If block comments may only be indented if they have some space
+characters before the leading `#` character in the input file, use
+**-isbc**.
+
+The manual shows many other options for controlling comments.
+
+## Outdenting Long Quotes
+
+Long quoted strings may exceed the specified line length limit. The
+default, when this happens, is to outdent them to the first column.
+Here is an example of an outdented long quote:
+
+ if ($source_stream) {
+ if ( @ARGV > 0 ) {
+ die
+ "You may not specify any filenames when a source array is given\n";
+ }
+ }
+
+The effect is not too different from using a here document to represent
+the quote. If you prefer to leave the quote indented, like this:
+
+ if ($source_stream) {
+ if ( @ARGV > 0 ) {
+ die
+ "You may not specify any filenames when a source array is given\n";
+ }
+ }
+
+use **-nolq**.
+
+## Many Other Parameters
+
+This document has only covered the most popular parameters. The manual
+contains many more and should be consulted if you did not find what you need
+here.
+
+## Example `.perltidyrc` files
+
+Now gather together all of the parameters you prefer and enter them
+in a file called `.perltidyrc`.
+
+Here are some example `.perltidyrc` files and the corresponding style.
+
+Here is a little test snippet, shown the way it would appear with
+the default style.
+
+ for (@methods) {
+ push (
+ @results,
+ {
+ name => $_->name,
+ help => $_->help,
+ }
+ );
+ }
+
+You do not need a `.perltidyrc` file for this style.
+
+Here is the same snippet
+
+ for (@methods)
+ {
+ push(@results,
+ { name => $_->name,
+ help => $_->help,
+ }
+ );
+ }
+
+for a `.perltidyrc` file containing these parameters:
+
+ -bl
+ -lp
+ -cti=1
+ -vt=1
+ -pt=2
+
+You do not need to place just one parameter per line, but this may be
+convenient for long lists. You may then hide any parameter by placing
+a `#` symbol before it.
+
+And here is the snippet
+
+ for (@methods) {
+ push ( @results,
+ { name => $_->name,
+ help => $_->help,
+ } );
+ }
+
+for a `.perltidyrc` file containing these parameters:
+
+ -lp
+ -vt=1
+ -vtc=1
+
+## Tidyview
+
+There is a graphical program called **tidyview** which you can use to read a
+preliminary `.perltidyrc` file, make trial adjustments and immediately see
+their effect on a test file, and then write a new `.perltidyrc`. You can
+download a copy at
+
+http://sourceforge.net/projects/tidyview
+
+## Additional Information
+
+This document has covered the main parameters. Many more parameters are
+available for special purposes and for fine-tuning a style. For complete
+information see the perltidy manual
+http://perltidy.sourceforge.net/perltidy.html
+
+For an introduction to using perltidy, see the tutorial
+http://perltidy.sourceforge.net/tutorial.html
+
+Suggestions for improving this document are welcome and may be sent to
+perltidy at users.sourceforge.net
+++ /dev/null
-<?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title></title>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:root@localhost" />
-</head>
-
-<body>
-
-
-
-<ul id="index">
- <li><a href="#A-Brief-Perltidy-Tutorial">A Brief Perltidy Tutorial</a>
- <ul>
- <li><a href="#A-First-Test">A First Test</a></li>
- <li><a href="#Indentation">Indentation</a></li>
- <li><a href="#Input-Flags">Input Flags</a></li>
- <li><a href="#Line-Length-and-Continuation-Indentation">Line Length and Continuation Indentation.</a></li>
- <li><a href="#Tabs-or-Spaces">Tabs or Spaces?</a></li>
- <li><a href="#Input-Output-Control">Input/Output Control</a></li>
- <li><a href="#Style-Variations">Style Variations</a></li>
- <li><a href="#Configuration-Files">Configuration Files</a></li>
- <li><a href="#Error-Reporting">Error Reporting</a></li>
- <li><a href="#The-Log-File">The Log File</a></li>
- <li><a href="#Using-Perltidy-as-a-Filter-on-Selected-Text-from-an-Editor">Using Perltidy as a Filter on Selected Text from an Editor</a></li>
- <li><a href="#Writing-an-HTML-File">Writing an HTML File</a></li>
- <li><a href="#Summary">Summary</a></li>
- </ul>
- </li>
-</ul>
-
-<h1 id="A-Brief-Perltidy-Tutorial">A Brief Perltidy Tutorial</h1>
-
-<p>Perltidy can save you a lot of tedious editing if you spend a few minutes learning to use it effectively. Perltidy is highly configurable, but for many programmers the default parameter set will be satisfactory, with perhaps a few additional parameters to account for style preferences.</p>
-
-<p>This tutorial assumes that perltidy has been installed on your system. Installation instructions accompany the package. To follow along with this tutorial, please find a small Perl script and place a copy in a temporary directory. For example, here is a small (and silly) script:</p>
-
-<pre><code> print "Help Desk -- What Editor do you use?";
- chomp($editor = <STDIN>);
- if ($editor =~ /emacs/i) {
- print "Why aren't you using vi?\n";
- } elsif ($editor =~ /vi/i) {
- print "Why aren't you using emacs?\n";
- } else {
- print "I think that's the problem\n";
- }</code></pre>
-
-<p>It is included in the <i>docs</i> section of the distribution.</p>
-
-<h2 id="A-First-Test">A First Test</h2>
-
-<p>Assume that the name of your script is <i>testfile.pl</i>. You can reformat it with the default options to use the style recommended in the perlstyle man pages with the command:</p>
-
-<pre><code> perltidy testfile.pl</code></pre>
-
-<p>For safety, perltidy never overwrites your original file. In this case, its output will go to a file named <i>testfile.pl.tdy</i>, which you should examine now with your editor. Here is what the above file looks like with the default options:</p>
-
-<pre><code> print "Help Desk -- What Editor do you use?";
- chomp( $editor = <STDIN> );
- if ( $editor =~ /emacs/i ) {
- print "Why aren't you using vi?\n";
- }
- elsif ( $editor =~ /vi/i ) {
- print "Why aren't you using emacs?\n";
- }
- else {
- print "I think that's the problem\n";
- }</code></pre>
-
-<p>You'll notice an immediate style change from the "cuddled-else" style of the original to the default "non-cuddled-else" style. This is because perltidy has to make some kind of default selection of formatting options, and this default tries to follow the suggestions in the perlstyle man pages.</p>
-
-<p>If you prefer the original "cuddled-else" style, don't worry, you can indicate that with a <b>-ce</b> flag. So if you rerun with that flag</p>
-
-<pre><code> perltidy -ce testfile.pl</code></pre>
-
-<p>you will see a return to the original "cuddled-else" style. There are many more parameters for controlling style, and some of the most useful of these are discussed below.</p>
-
-<h2 id="Indentation">Indentation</h2>
-
-<p>Another noticeable difference between the original and the reformatted file is that the indentation has been changed from 2 spaces to 4 spaces. That's because 4 spaces is the default. You may change this to be a different number with <b>-i=n</b>.</p>
-
-<p>To get some practice, try these examples, and examine the resulting <i>testfile.pl.tdy</i> file:</p>
-
-<pre><code> perltidy -i=8 testfile.pl</code></pre>
-
-<p>This changes the default of 4 spaces per indentation level to be 8. Now just to emphasize the point, try this and examine the result:</p>
-
-<pre><code> perltidy -i=0 testfile.pl</code></pre>
-
-<p>There will be no indentation at all in this case.</p>
-
-<h2 id="Input-Flags">Input Flags</h2>
-
-<p>This is a good place to mention a few points regarding the input flags. First, for each option, there are two forms, a long form and a short form, and either may be used.</p>
-
-<p>For example, if you want to change the number of columns corresponding to one indentation level to 3 (from the default of 4) you may use either</p>
-
-<pre><code> -i=3 or --indent-columns=3</code></pre>
-
-<p>The short forms are convenient for entering parameters by hand, whereas the long forms, though often ridiculously long, are self-documenting and therefore useful in configuration scripts. You may use either one or two dashes ahead of the parameters. Also, the '=' sign is optional, and may be a single space instead. However, the value of a parameter must NOT be adjacent to the flag, like this <b>-i3</b> (WRONG). Also, flags must be input separately, never bundled together.</p>
-
-<h2 id="Line-Length-and-Continuation-Indentation">Line Length and Continuation Indentation.</h2>
-
-<p>If you change the indentation spaces you will probably also need to change the continuation indentation spaces with the parameter <b>-ci=n</b>. The continuation indentation is the extra indentation -- 2 spaces by default -- given to that portion of a long line which has been placed below the start of a statement. For example:</p>
-
-<pre><code> croak "Couldn't pop genome file"
- unless sysread( $impl->{file}, $element, $impl->{group} )
- and truncate( $impl->{file}, $new_end );</code></pre>
-
-<p>There is no fixed rule for setting the value for <b>-ci=n</b>, but it should probably not exceed one-half of the number of spaces of a full indentation level.</p>
-
-<p>In the above snippet, the statement was broken into three lines. The actual number is governed by a parameter, the maximum line length, as well as by what perltidy considers to be good break points. The maximum line length is 80 characters by default. You can change this to be any number <b>n</b> with the <b>-l=n</b> flag. Perltidy tries to produce lines which do not exceed this length, and it does this by finding good break points. For example, the above snippet would look like this with <b>perltidy -l=40</b>:</p>
-
-<pre><code> croak "Couldn't pop genome file"
- unless
- sysread( $impl->{file}, $element,
- $impl->{group} )
- and
- truncate( $impl->{file}, $new_end );</code></pre>
-
-<p>You may be wondering what would happen with, say, <b>-l=1</b>. Go ahead and try it.</p>
-
-<h2 id="Tabs-or-Spaces">Tabs or Spaces?</h2>
-
-<p>With indentation, there is always a tab issue to resolve. By default, perltidy will use leading ascii space characters instead of tabs. The reason is that this will be displayed correctly by virtually all editors, and in the long run, will avoid maintenance problems.</p>
-
-<p>However, if you prefer, you may have perltidy entab the leading whitespace of a line with the command <b>-et=n</b>, where <b>n</b> is the number of spaces which will be represented by one tab. But note that your text will not be displayed properly unless viewed with software that is configured to display <b>n</b> spaces per tab.</p>
-
-<h2 id="Input-Output-Control">Input/Output Control</h2>
-
-<p>In the first example, we saw that if we pass perltidy the name of a file on the command line, it reformats it and creates a new filename by appending an extension, <i>.tdy</i>. This is the default behavior, but there are several other options.</p>
-
-<p>On most systems, you may use wildcards to reformat a whole batch of files at once, like this for example:</p>
-
-<pre><code> perltidy *.pl</code></pre>
-
-<p>and in this case, each of the output files will be have a name equal to the input file with the extension <i>.tdy</i> appended. If you decide that the formatting is acceptable, you will want to backup your originals and then remove the <i>.tdy</i> extensions from the reformatted files. There is an powerful perl script called <code>rename</code> that can be used for this purpose; if you don't have it, you can find it for example in <b>The Perl Cookbook</b>.</p>
-
-<p>If you find that the formatting done by perltidy is usually acceptable, you may want to save some effort by letting perltidy do a simple backup of the original files and then reformat them in place. You specify this with a <b>-b</b> flag. For example, the command</p>
-
-<pre><code> perltidy -b *.pl</code></pre>
-
-<p>will rename the original files by appending a <i>.bak</i> extension, and then create reformatted files with the same names as the originals. (If you don't like the default backup extension choice <i>.bak</i>, the manual tells how to change it). Each time you run perltidy with the <b>-b</b> option, the previous <i>.bak</i> files will be overwritten, so please make regular separate backups.</p>
-
-<p>If there is no input filename specified on the command line, then input is assumed to come from standard input and output will go to standard output. On systems with a Unix-like interface, you can use perltidy as a filter, like this:</p>
-
-<pre><code> perltidy <somefile.pl >newfile.pl</code></pre>
-
-<p>What happens in this case is that the shell takes care of the redirected input files, '<somefile.pl', and so perltidy never sees the filename. Therefore, it knows to use the standard input and standard output channels.</p>
-
-<p>If you are executing perltidy on a file and want to force the output to standard output, rather than create a <i>.tdy</i> file, you can indicate this with the flag <b>-st</b>, like this:</p>
-
-<pre><code> perltidy somefile.pl -st >otherfile.pl</code></pre>
-
-<p>You can also control the name of the output file with the <b>-o</b> flag, like this:</p>
-
-<pre><code> perltidy testfile.pl -o=testfile.new.pl</code></pre>
-
-<h2 id="Style-Variations">Style Variations</h2>
-
-<p>Perltidy has to make some kind of default selection of formatting options, and its choice is to try to follow the suggestions in the perlstyle man pages. Many programmers more or less follow these suggestions with a few exceptions. In this section we will look at just a few of the most commonly used style parameters. Later, you may want to systematically develop a set of style parameters with the help of the perltidy <b>stylekey</b> web page at http://perltidy.sourceforge.net/stylekey.html</p>
-
-<dl>
-
-<dt id="ce-cuddled-elses"><b>-ce</b>, cuddled elses</dt>
-<dd>
-
-<p>If you prefer cuddled elses, use the <b>-ce</b> flag.</p>
-
-</dd>
-<dt id="bl-braces-left"><b>-bl</b>, braces left</dt>
-<dd>
-
-<p>Here is what the <code>if</code> block in the above script looks like with <b>-bl</b>:</p>
-
-<pre><code> if ( $editor =~ /emacs/i )
- {
- print "Why aren't you using vi?\n";
- }
- elsif ( $editor =~ /vi/i )
- {
- print "Why aren't you using emacs?\n";
- }
- else
- {
- print "I think that's the problem\n";
- }</code></pre>
-
-</dd>
-<dt id="lp-Lining-up-with-parentheses"><b>-lp</b>, Lining up with parentheses</dt>
-<dd>
-
-<p>The <b>-lp</b> parameter can enhance the readability of lists by adding extra indentation. Consider:</p>
-
-<pre><code> %romanNumerals = (
- one => 'I',
- two => 'II',
- three => 'III',
- four => 'IV',
- five => 'V',
- six => 'VI',
- seven => 'VII',
- eight => 'VIII',
- nine => 'IX',
- ten => 'X'
- );</code></pre>
-
-<p>With the <b>-lp</b> flag, this is formatted as:</p>
-
-<pre><code> %romanNumerals = (
- one => 'I',
- two => 'II',
- three => 'III',
- four => 'IV',
- five => 'V',
- six => 'VI',
- seven => 'VII',
- eight => 'VIII',
- nine => 'IX',
- ten => 'X'
- );</code></pre>
-
-<p>which is preferred by some. (I've actually used <b>-lp</b> and <b>-cti=1</b> to format this block. The <b>-cti=1</b> flag causes the closing paren to align vertically with the opening paren, which works well with the <b>-lp</b> indentation style). An advantage of <b>-lp</b> indentation are that it displays lists nicely. A disadvantage is that deeply nested lists can require a long line length.</p>
-
-</dd>
-<dt id="bt--pt--sbt:-Container-tightness"><b>-bt</b>,<b>-pt</b>,<b>-sbt</b>: Container tightness</dt>
-<dd>
-
-<p>These are parameters for controlling the amount of space within containing parentheses, braces, and square brackets. The example below shows the effect of the three possible values, 0, 1, and 2, for the case of parentheses:</p>
-
-<pre><code> if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
- if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
- if ((my $len_tab = length($tabstr)) > 0) { # -pt=2</code></pre>
-
-<p>A value of 0 causes all parens to be padded on the inside with a space, and a value of 2 causes this never to happen. With a value of 1, spaces will be introduced if the item within is more than a single token.</p>
-
-</dd>
-</dl>
-
-<h2 id="Configuration-Files">Configuration Files</h2>
-
-<p>While style preferences vary, most people would agree that it is important to maintain a uniform style within a script, and this is a major benefit provided by perltidy. Once you have decided on which, if any, special options you prefer, you may want to avoid having to enter them each time you run it. You can do this by creating a special file named <i>.perltidyrc</i> in either your home directory, your current directory, or certain system-dependent locations. (Note the leading "." in the file name).</p>
-
-<p>A handy command to know when you start using a configuration file is</p>
-
-<pre><code> perltidy -dpro</code></pre>
-
-<p>which will dump to standard output the search that perltidy makes when looking for a configuration file, and the contents of the one that it selects, if any. This is one of a number of useful "dump and die" commands, in which perltidy will dump some information to standard output and then immediately exit. Others include <b>-h</b>, which dumps help information, and <b>-v</b>, which dumps the version number.</p>
-
-<p>Another useful command when working with configuration files is</p>
-
-<pre><code> perltidy -pro=file</code></pre>
-
-<p>which causes the contents of <i>file</i> to be used as the configuration file instead of a <i>.perltidyrc</i> file. With this command, you can easily switch among several different candidate configuration files during testing.</p>
-
-<p>This <i>.perltidyrc</i> file is free format. It is 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. Blank lines are ignored, and text after a '#' is ignored to the end of a line.</p>
-
-<p>Here is an example of a <i>.perltidyrc</i> file:</p>
-
-<pre><code> # This is a simple of a .perltidyrc configuration file
- # This implements a highly spaced style
- -bl # braces on new lines
- -pt=0 # parens not tight at all
- -bt=0 # braces not tight
- -sbt=0 # square brackets not tight</code></pre>
-
-<p>If you experiment with this file, remember that it is in your directory, since if you are running on a Unix system, files beginning with a "." are normally hidden.</p>
-
-<p>If you have a <i>.perltidyrc</i> file, and want perltidy to ignore it, use the <b>-npro</b> flag on the command line.</p>
-
-<h2 id="Error-Reporting">Error Reporting</h2>
-
-<p>Let's run through a 'fire drill' to see how perltidy reports errors. Try introducing an extra opening brace somewhere in a test file. For example, introducing an extra brace in the file listed above produces the following message on the terminal (or standard error output):</p>
-
-<pre><code> ## Please see file testfile.pl.ERR!</code></pre>
-
-<p>Here is what <i>testfile.pl.ERR</i> contains:</p>
-
-<pre><code> 10: final indentation level: 1
-
- Final nesting depth of '{'s is 1
- The most recent un-matched '{' is on line 6
- 6: } elsif ($temperature < 68) {{
- ^</code></pre>
-
-<p>This shows how perltidy will, by default, write error messages to a file with the extension <i>.ERR</i>, and it will write a note that it did so to the standard error device. If you would prefer to have the error messages sent to standard output, instead of to a <i>.ERR</i> file, use the <b>-se</b> flag.</p>
-
-<p>Almost every programmer would want to see error messages of this type, but there are a number of messages which, if reported, would be annoying. To manage this problem, perltidy puts its messages into two categories: errors and warnings. The default is to just report the errors, but you can control this with input flags, as follows:</p>
-
-<pre><code> flag what this does
- ---- --------------
- default: report errors but not warnings
- -w report all errors and warnings
- -q quiet! do not report either errors or warnings</code></pre>
-
-<p>The default is generally a good choice, but it's not a bad idea to check programs with <b>-w</b> occasionally, especially if your are looking for a bug. For example, it will ask if you really want '=' instead of '=~' in this line:</p>
-
-<pre><code> $line = s/^\s*//;</code></pre>
-
-<p>This kind of error can otherwise be hard to find.</p>
-
-<h2 id="The-Log-File">The Log File</h2>
-
-<p>One last topic that needs to be touched upon concerns the <i>.LOG</i> file. This is where perltidy records messages that are not normally of any interest, but which just might occasionally be useful. This file is not saved, though, unless perltidy detects that it has made a mistake or you ask for it to be saved.</p>
-
-<p>There are a couple of ways to ask perltidy to save a log file. To create a relatively sparse log file, use</p>
-
-<pre><code> perltidy -log testfile.pl</code></pre>
-
-<p>and for a verbose log file, use</p>
-
-<pre><code> perltidy -g testfile.pl</code></pre>
-
-<p>The difference is that the first form only saves detailed information at least every 50th line, while the second form saves detailed information about every line.</p>
-
-<p>So returning to our example, lets force perltidy to save a verbose log file by issuing the following command</p>
-
-<pre><code> perltidy -g testfile.pl</code></pre>
-
-<p>You will find that a file named <i>testfile.pl.LOG</i> has been created in your directory.</p>
-
-<p>If you open this file, you will see that it is a text file with a combination of warning messages and informative messages. All you need to know for now is that it exists; someday it may be useful.</p>
-
-<h2 id="Using-Perltidy-as-a-Filter-on-Selected-Text-from-an-Editor">Using Perltidy as a Filter on Selected Text from an Editor</h2>
-
-<p>Most programmer's editors allow a selected group of lines to be passed through an external filter. Perltidy has been designed to work well as a filter, and it is well worthwhile learning the appropriate commands to do this with your editor. This means that you can enter a few keystrokes and watch a block of text get reformatted. If you are not doing this, you are missing out of a lot of fun! You may want to supply the <b>-q</b> flag to prevent error messages regarding incorrect syntax, since errors may be obvious in the indentation of the reformatted text. This is entirely optional, but if you do not use the <b>-q</b> flag, you will need to use the undo keys in case an error message appears on the screen.</p>
-
-<p>For example, within the <b>vim</b> editor it is only necessary to select the text by any of the text selection methods, and then issue the command !perltidy in command mode. Thus, an entire file can be formatted using</p>
-
-<pre><code> :%!perltidy -q</code></pre>
-
-<p>or, without the <b>-q</b> flag, just</p>
-
-<pre><code> :%!perltidy</code></pre>
-
-<p>It isn't necessary to format an entire file, however. Perltidy will probably work well as long as you select blocks of text whose braces, parentheses, and square brackets are properly balanced. You can even format an <code>elsif</code> block without the leading <code>if</code> block, as long as the text you select has all braces balanced.</p>
-
-<p>For the <b>emacs</b> editor, first mark a region and then pipe it through perltidy. For example, to format an entire file, select it with <code>C-x h</code> and then pipe it with <code>M-1 M-|</code> and then <code>perltidy</code>. The numeric argument, <code>M-1</code> causes the output from perltidy to replace the marked text. See "GNU Emacs Manual" for more information, http://www.gnu.org/manual/emacs-20.3/html_node/emacs_toc.html</p>
-
-<p>If you have difficulty with an editor, try the <b>-st</b> flag, which will force perltidy to send output to standard output. This might be needed, for example, if the editor passes text to perltidy as temporary filename instead of through the standard input. If this works, you might put the <b>-st</b> flag in your <i>.perltidyrc</i> file.</p>
-
-<p>If you have some tips for making perltidy work with your editor, and are willing to share them, please email me (see below) and I'll try to incorporate them in this document or put up a link to them.</p>
-
-<p>After you get your editor and perltidy successfully talking to each other, try formatting a snippet of code with a brace error to see what happens. (Do not use the quiet flag, <b>-q</b>, for this test). Perltidy will send one line starting with <code>##</code> to standard error output. Your editor may either display it at the top of the reformatted text or at the bottom (or even midstream!). You probably cannot control this, and perltidy can't, but you need to know where to look when an actual error is detected.</p>
-
-<h2 id="Writing-an-HTML-File">Writing an HTML File</h2>
-
-<p>Perltidy can switch between two different output modes. We have been discussing what might be called its "beautifier" mode, but it can also output in HTML. To do this, use the <b>-html</b> flag, like this:</p>
-
-<pre><code> perltidy -html testfile.pl</code></pre>
-
-<p>which will produce a file <i>testfile.pl.html</i>. There are many parameters available for adjusting the appearance of an HTML file, but a very easy way is to just write the HTML file with this simple command and then edit the stylesheet which is embedded at its top.</p>
-
-<p>One important thing to know about the <b>-html</b> flag is that perltidy can either send its output to its beautifier or to its HTML writer, but (unfortunately) not both in a single run. So the situation can be represented like this:</p>
-
-<pre><code> ------------
- | | --->beautifier--> testfile.pl.tdy
- testfile.pl --> | perltidy | -->
- | | --->HTML -------> testfile.pl.html
- ------------</code></pre>
-
-<p>And in the future, there may be more output filters. So if you would like to both beautify a script and write it to HTML, you need to do it in two steps.</p>
-
-<h2 id="Summary">Summary</h2>
-
-<p>That's enough to get started using perltidy. When you are ready to create a <i>.perltidyrc</i> file, you may find it helpful to use the <i>stylekey</i> page as a guide at http://perltidy.sourceforge.net/stylekey.html</p>
-
-<p>Many additional special features and capabilities can be found in the manual pages for perltidy at http://perltidy.sourceforge.net/perltidy.html</p>
-
-<p>We hope that perltidy makes perl programming a little more fun. Please check the perltidy web site http://perltidy.sourceforge.net occasionally for updates.</p>
-
-<p>The author may be contacted at perltidy at users.sourceforge.net.</p>
-
-
-</body>
-
-</html>
-
-
--- /dev/null
+# A Brief Perltidy Tutorial
+
+Perltidy can save you a lot of tedious editing if you spend a few
+minutes learning to use it effectively. Perltidy is highly
+configurable, but for many programmers the default parameter set will be
+satisfactory, with perhaps a few additional parameters to account for
+style preferences.
+
+This tutorial assumes that perltidy has been installed on your system.
+Installation instructions accompany the package. To follow along with
+this tutorial, please find a small Perl script and place a copy in a
+temporary directory. For example, here is a small (and silly) script:
+
+ print "Help Desk -- What Editor do you use?";
+ chomp($editor = <STDIN>);
+ if ($editor =~ /emacs/i) {
+ print "Why aren't you using vi?\n";
+ } elsif ($editor =~ /vi/i) {
+ print "Why aren't you using emacs?\n";
+ } else {
+ print "I think that's the problem\n";
+ }
+
+It is included in the `docs` section of the distribution.
+
+## A First Test
+
+Assume that the name of your script is `testfile.pl`. You can reformat it
+with the default options to use the style recommended in the perlstyle man
+pages with the command:
+
+ perltidy testfile.pl
+
+For safety, perltidy never overwrites your original file. In this case,
+its output will go to a file named `testfile.pl.tdy`, which you should
+examine now with your editor. Here is what the above file looks like
+with the default options:
+
+ print "Help Desk -- What Editor do you use?";
+ chomp( $editor = <STDIN> );
+ if ( $editor =~ /emacs/i ) {
+ print "Why aren't you using vi?\n";
+ }
+ elsif ( $editor =~ /vi/i ) {
+ print "Why aren't you using emacs?\n";
+ }
+ else {
+ print "I think that's the problem\n";
+ }
+
+You'll notice an immediate style change from the "cuddled-else" style of
+the original to the default "non-cuddled-else" style. This is because
+perltidy has to make some kind of default selection of formatting
+options, and this default tries to follow the suggestions in the
+perlstyle man pages.
+
+If you prefer the original "cuddled-else" style, don't worry, you can
+indicate that with a **-ce** flag. So if you rerun with that flag
+
+ perltidy -ce testfile.pl
+
+you will see a return to the original "cuddled-else" style. There are
+many more parameters for controlling style, and some of the most useful
+of these are discussed below.
+
+## Indentation
+
+Another noticeable difference between the original and the reformatted
+file is that the indentation has been changed from 2 spaces to 4 spaces.
+That's because 4 spaces is the default. You may change this to be a
+different number with **-i=n**.
+
+To get some practice, try these examples, and examine the resulting
+`testfile.pl.tdy` file:
+
+ perltidy -i=8 testfile.pl
+
+This changes the default of 4 spaces per indentation level to be 8. Now
+just to emphasize the point, try this and examine the result:
+
+ perltidy -i=0 testfile.pl
+
+There will be no indentation at all in this case.
+
+## Input Flags
+
+This is a good place to mention a few points regarding the input flags.
+First, for each option, there are two forms, a long form and a short
+form, and either may be used.
+
+For example, if you want to change the number of columns corresponding to one
+indentation level to 3 (from the default of 4) you may use either
+
+ -i=3 or --indent-columns=3
+
+The short forms are convenient for entering parameters by hand, whereas
+the long forms, though often ridiculously long, are self-documenting and
+therefore useful in configuration scripts. You may use either one or
+two dashes ahead of the parameters. Also, the '=' sign is optional,
+and may be a single space instead. However, the value of a parameter
+must NOT be adjacent to the flag, like this **-i3** (WRONG). Also,
+flags must be input separately, never bundled together.
+
+## Line Length and Continuation Indentation.
+
+If you change the indentation spaces you will probably also need to
+change the continuation indentation spaces with the parameter **-ci=n**.
+The continuation indentation is the extra indentation -- 2 spaces by
+default -- given to that portion of a long line which has been placed
+below the start of a statement. For example:
+
+ croak "Couldn't pop genome file"
+ unless sysread( $impl->{file}, $element, $impl->{group} )
+ and truncate( $impl->{file}, $new_end );
+
+There is no fixed rule for setting the value for **-ci=n**, but it should
+probably not exceed one-half of the number of spaces of a full
+indentation level.
+
+In the above snippet, the statement was broken into three lines. The
+actual number is governed by a parameter, the maximum line length, as
+well as by what perltidy considers to be good break points. The maximum
+line length is 80 characters by default. You can change this to be any
+number **n** with the **-l=n** flag. Perltidy tries to produce lines
+which do not exceed this length, and it does this by finding good break
+points. For example, the above snippet would look like this with
+**perltidy -l=40**:
+
+ croak "Couldn't pop genome file"
+ unless
+ sysread( $impl->{file}, $element,
+ $impl->{group} )
+ and
+ truncate( $impl->{file}, $new_end );
+
+You may be wondering what would happen with, say, **-l=1**. Go
+ahead and try it.
+
+## Tabs or Spaces?
+
+With indentation, there is always a tab issue to resolve. By default,
+perltidy will use leading ascii space characters instead of tabs. The
+reason is that this will be displayed correctly by virtually all
+editors, and in the long run, will avoid maintenance problems.
+
+However, if you prefer, you may have perltidy entab the leading
+whitespace of a line with the command **-et=n**, where **n** is the number
+of spaces which will be represented by one tab. But note that your text
+will not be displayed properly unless viewed with software that is
+configured to display **n** spaces per tab.
+
+## Input/Output Control
+
+In the first example, we saw that if we pass perltidy the name
+of a file on the command line, it reformats it and creates a
+new filename by appending an extension, `.tdy`. This is the
+default behavior, but there are several other options.
+
+On most systems, you may use wildcards to reformat a whole batch of
+files at once, like this for example:
+
+ perltidy *.pl
+
+and in this case, each of the output files will be have a name equal to
+the input file with the extension `.tdy` appended. If you decide that
+the formatting is acceptable, you will want to backup your originals and
+then remove the `.tdy` extensions from the reformatted files. There is
+an powerful perl script called `rename` that can be used for this
+purpose; if you don't have it, you can find it for example in **The Perl
+Cookbook**.
+
+If you find that the formatting done by perltidy is usually acceptable,
+you may want to save some effort by letting perltidy do a simple backup
+of the original files and then reformat them in place. You specify this
+with a **-b** flag. For example, the command
+
+ perltidy -b *.pl
+
+will rename the original files by appending a `.bak` extension, and then
+create reformatted files with the same names as the originals. (If you don't
+like the default backup extension choice `.bak`, the manual tells how to
+change it). Each time you run perltidy with the **-b** option, the previous
+`.bak` files will be overwritten, so please make regular separate backups.
+
+If there is no input filename specified on the command line, then input
+is assumed to come from standard input and output will go to standard
+output. On systems with a Unix-like interface, you can use perltidy as
+a filter, like this:
+
+ perltidy <somefile.pl >newfile.pl
+
+What happens in this case is that the shell takes care of the redirected
+input files, '<somefile.pl', and so perltidy never sees the filename.
+Therefore, it knows to use the standard input and standard output
+channels.
+
+If you are executing perltidy on a file and want to force the output
+to standard output, rather than create a `.tdy` file, you can
+indicate this with the flag **-st**, like this:
+
+ perltidy somefile.pl -st >otherfile.pl
+
+You can also control the name of the output file with the **-o** flag,
+like this:
+
+ perltidy testfile.pl -o=testfile.new.pl
+
+## Style Variations
+
+Perltidy has to make some kind of default selection of formatting
+options, and its choice is to try to follow the suggestions in the
+perlstyle man pages. Many programmers more or less follow these
+suggestions with a few exceptions. In this section we will
+look at just a few of the most commonly used style parameters. Later,
+you may want to systematically develop a set of style
+parameters with the help of
+the perltidy **stylekey** web page at
+http://perltidy.sourceforge.net/stylekey.html
+
+- **-ce**, cuddled elses
+
+ If you prefer cuddled elses, use the **-ce** flag.
+
+- **-bl**, braces left
+
+ Here is what the `if` block in the above script looks like with **-bl**:
+
+ if ( $editor =~ /emacs/i )
+ {
+ print "Why aren't you using vi?\n";
+ }
+ elsif ( $editor =~ /vi/i )
+ {
+ print "Why aren't you using emacs?\n";
+ }
+ else
+ {
+ print "I think that's the problem\n";
+ }
+
+- **-lp**, Lining up with parentheses
+
+ The **-lp** parameter can enhance the readability of lists by adding
+ extra indentation. Consider:
+
+ %romanNumerals = (
+ one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV',
+ five => 'V',
+ six => 'VI',
+ seven => 'VII',
+ eight => 'VIII',
+ nine => 'IX',
+ ten => 'X'
+ );
+
+ With the **-lp** flag, this is formatted as:
+
+ %romanNumerals = (
+ one => 'I',
+ two => 'II',
+ three => 'III',
+ four => 'IV',
+ five => 'V',
+ six => 'VI',
+ seven => 'VII',
+ eight => 'VIII',
+ nine => 'IX',
+ ten => 'X'
+ );
+
+ which is preferred by some. (I've actually used **-lp** and **-cti=1** to
+ format this block. The **-cti=1** flag causes the closing paren to align
+ vertically with the opening paren, which works well with the **-lp**
+ indentation style). An advantage of **-lp** indentation are that it
+ displays lists nicely. A disadvantage is that deeply nested lists can
+ require a long line length.
+
+- **-bt**,**-pt**,**-sbt**: Container tightness
+
+ These are parameters for controlling the amount of space within
+ containing parentheses, braces, and square brackets. The example below
+ shows the effect of the three possible values, 0, 1, and 2, for the case
+ of parentheses:
+
+ if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
+ if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
+ if ((my $len_tab = length($tabstr)) > 0) { # -pt=2
+
+ A value of 0 causes all parens to be padded on the inside with a space,
+ and a value of 2 causes this never to happen. With a value of 1, spaces
+ will be introduced if the item within is more than a single token.
+
+## Configuration Files
+
+While style preferences vary, most people would agree that it is
+important to maintain a uniform style within a script, and this is a
+major benefit provided by perltidy. Once you have decided on which, if
+any, special options you prefer, you may want to avoid having to enter
+them each time you run it. You can do this by creating a special file
+named `.perltidyrc` in either your home directory, your current
+directory, or certain system-dependent locations. (Note the leading "."
+in the file name).
+
+A handy command to know when you start using a configuration file is
+
+ perltidy -dpro
+
+which will dump to standard output the search that perltidy makes when
+looking for a configuration file, and the contents of the one that it
+selects, if any. This is one of a number of useful "dump and die"
+commands, in which perltidy will dump some information to standard
+output and then immediately exit. Others include **-h**, which dumps
+help information, and **-v**, which dumps the version number.
+
+Another useful command when working with configuration files is
+
+ perltidy -pro=file
+
+which causes the contents of `file` to be used as the configuration
+file instead of a `.perltidyrc` file. With this command, you can
+easily switch among several different candidate configuration files
+during testing.
+
+This `.perltidyrc` file is free format. It is 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. Blank lines are
+ignored, and text after a '#' is ignored to the end of a line.
+
+Here is an example of a `.perltidyrc` file:
+
+ # This is a simple of a .perltidyrc configuration file
+ # This implements a highly spaced style
+ -bl # braces on new lines
+ -pt=0 # parens not tight at all
+ -bt=0 # braces not tight
+ -sbt=0 # square brackets not tight
+
+If you experiment with this file, remember that it is in your directory,
+since if you are running on a Unix system, files beginning with a "."
+are normally hidden.
+
+If you have a `.perltidyrc` file, and want perltidy to ignore it,
+use the **-npro** flag on the command line.
+
+## Error Reporting
+
+Let's run through a 'fire drill' to see how perltidy reports errors. Try
+introducing an extra opening brace somewhere in a test file. For example,
+introducing an extra brace in the file listed above produces the following
+message on the terminal (or standard error output):
+
+ ## Please see file testfile.pl.ERR!
+
+Here is what `testfile.pl.ERR` contains:
+
+ 10: final indentation level: 1
+
+ Final nesting depth of '{'s is 1
+ The most recent un-matched '{' is on line 6
+ 6: } elsif ($temperature < 68) {{
+ ^
+
+This shows how perltidy will, by default, write error messages to a file
+with the extension `.ERR`, and it will write a note that it did so to
+the standard error device. If you would prefer to have the error
+messages sent to standard output, instead of to a `.ERR` file, use the
+**-se** flag.
+
+Almost every programmer would want to see error messages of this type,
+but there are a number of messages which, if reported, would be
+annoying. To manage this problem, perltidy puts its messages into two
+categories: errors and warnings. The default is to just report the
+errors, but you can control this with input flags, as follows:
+
+ flag what this does
+ ---- --------------
+ default: report errors but not warnings
+ -w report all errors and warnings
+ -q quiet! do not report either errors or warnings
+
+The default is generally a good choice, but it's not a bad idea to check
+programs with **-w** occasionally, especially if your are looking for a
+bug. For example, it will ask if you really want '=' instead of '=~' in
+this line:
+
+ $line = s/^\s*//;
+
+This kind of error can otherwise be hard to find.
+
+## The Log File
+
+One last topic that needs to be touched upon concerns the `.LOG` file.
+This is where perltidy records messages that are not normally of any
+interest, but which just might occasionally be useful. This file is not
+saved, though, unless perltidy detects that it has made a mistake or you
+ask for it to be saved.
+
+There are a couple of ways to ask perltidy to save a log file. To
+create a relatively sparse log file, use
+
+ perltidy -log testfile.pl
+
+and for a verbose log file, use
+
+ perltidy -g testfile.pl
+
+The difference is that the first form only saves detailed information at
+least every 50th line, while the second form saves detailed information
+about every line.
+
+So returning to our example, lets force perltidy to save a
+verbose log file by issuing the following command
+
+ perltidy -g testfile.pl
+
+You will find that a file named `testfile.pl.LOG` has been
+created in your directory.
+
+If you open this file, you will see that it is a text file with a
+combination of warning messages and informative messages. All you need
+to know for now is that it exists; someday it may be useful.
+
+## Using Perltidy as a Filter on Selected Text from an Editor
+
+Most programmer's editors allow a selected group of lines to be passed
+through an external filter. Perltidy has been designed to work well as
+a filter, and it is well worthwhile learning the appropriate commands to
+do this with your editor. This means that you can enter a few
+keystrokes and watch a block of text get reformatted. If you are not
+doing this, you are missing out of a lot of fun! You may want to supply
+the **-q** flag to prevent error messages regarding incorrect syntax,
+since errors may be obvious in the indentation of the reformatted text.
+This is entirely optional, but if you do not use the **-q** flag, you
+will need to use the undo keys in case an error message appears on the
+screen.
+
+For example, within the **vim** editor it is only necessary to select the
+text by any of the text selection methods, and then issue the command
+!perltidy in command mode. Thus, an entire file can be formatted using
+
+ :%!perltidy -q
+
+or, without the **-q** flag, just
+
+ :%!perltidy
+
+It isn't necessary to format an entire file, however. Perltidy will
+probably work well as long as you select blocks of text whose braces,
+parentheses, and square brackets are properly balanced. You can
+even format an `elsif` block without the leading `if` block, as
+long as the text you select has all braces balanced.
+
+For the **emacs** editor, first mark a region and then pipe it through
+perltidy. For example, to format an entire file, select it with `C-x h`
+and then pipe it with `M-1 M-|` and then `perltidy`. The numeric
+argument, `M-1` causes the output from perltidy to replace the marked
+text. See "GNU Emacs Manual" for more information,
+http://www.gnu.org/manual/emacs-20.3/html\_node/emacs\_toc.html
+
+If you have difficulty with an editor, try the **-st** flag, which will
+force perltidy to send output to standard output. This might be needed,
+for example, if the editor passes text to perltidy as temporary filename
+instead of through the standard input. If this works, you might put the
+**-st** flag in your `.perltidyrc` file.
+
+If you have some tips for making perltidy work with your editor, and
+are willing to share them, please email me (see below) and I'll try to
+incorporate them in this document or put up a link to them.
+
+After you get your editor and perltidy successfully talking to each
+other, try formatting a snippet of code with a brace error to see what
+happens. (Do not use the quiet flag, **-q**, for this test). Perltidy
+will send one line starting with `##` to standard error output. Your
+editor may either display it at the top of the reformatted text or at
+the bottom (or even midstream!). You probably cannot control this, and
+perltidy can't, but you need to know where to look when an actual error
+is detected.
+
+## Writing an HTML File
+
+Perltidy can switch between two different output modes. We have been
+discussing what might be called its "beautifier" mode, but it can also
+output in HTML. To do this, use the **-html** flag, like this:
+
+ perltidy -html testfile.pl
+
+which will produce a file `testfile.pl.html`. There are many
+parameters available for adjusting the appearance of an HTML file, but a
+very easy way is to just write the HTML file with this simple command
+and then edit the stylesheet which is embedded at its top.
+
+One important thing to know about the **-html** flag is that perltidy can
+either send its output to its beautifier or to its HTML writer, but
+(unfortunately) not both in a single run. So the situation can be
+represented like this:
+
+ ------------
+ | | --->beautifier--> testfile.pl.tdy
+ testfile.pl --> | perltidy | -->
+ | | --->HTML -------> testfile.pl.html
+ ------------
+
+And in the future, there may be more output filters. So if you would
+like to both beautify a script and write it to HTML, you need to do it
+in two steps.
+
+## Summary
+
+That's enough to get started using perltidy.
+When you are ready to create a `.perltidyrc` file, you may find it
+helpful to use the `stylekey` page as a guide at
+http://perltidy.sourceforge.net/stylekey.html
+
+Many additional special
+features and capabilities can be found in the manual pages for perltidy
+at
+http://perltidy.sourceforge.net/perltidy.html
+
+We hope that perltidy makes perl programming a little more fun.
+Please check the perltidy
+web site http://perltidy.sourceforge.net occasionally
+for updates.
+
+The author may be contacted at perltidy at users.sourceforge.net.
);
@is_digraph{@q} = (1) x scalar(@q);
- @q = qw( ... **= <<= >>= &&= ||= //= <=> <<~ );
+ @q = qw( ... **= <<= >>= &&= ||= //= <=> <<~ );
@is_trigraph{@q} = (1) x scalar(@q);
@q = qw(
@q = qw(is if unless and or err last next redo return);
@is_if_unless_and_or_last_next_redo_return{@q} = (1) x scalar(@q);
- @q = qw(last next redo return);
+ @q = qw(last next redo return);
@is_last_next_redo_return{@q} = (1) x scalar(@q);
- @q = qw(sort map grep);
+ @q = qw(sort map grep);
@is_sort_map_grep{@q} = (1) x scalar(@q);
- @q = qw(sort map grep eval);
+ @q = qw(sort map grep eval);
@is_sort_map_grep_eval{@q} = (1) x scalar(@q);
- @q = qw(sort map grep eval do);
+ @q = qw(sort map grep eval do);
@is_sort_map_grep_eval_do{@q} = (1) x scalar(@q);
- @q = qw(if unless);
+ @q = qw(if unless);
@is_if_unless{@q} = (1) x scalar(@q);
- @q = qw(and or err);
+ @q = qw(and or err);
@is_and_or{@q} = (1) x scalar(@q);
# Identify certain operators which often occur in chains.
# Checkbutton => 'Transmission checked',
# -variable => \$TRANS
# This usually improves appearance so it seems ok.
- @q = qw(&& || and or : ? . + - * /);
+ @q = qw(&& || and or : ? . + - * /);
@is_chain_operator{@q} = (1) x scalar(@q);
# We can remove semicolons after blocks preceded by these keywords
@ok_to_add_semicolon_for_block_type{@q} = (1) x scalar(@q);
# 'L' is token for opening { at hash key
- @q = qw< L { ( [ >;
+ @q = qw< L { ( [ >;
@is_opening_type{@q} = (1) x scalar(@q);
# 'R' is token for closing } at hash key
- @q = qw< R } ) ] >;
+ @q = qw< R } ) ] >;
@is_closing_type{@q} = (1) x scalar(@q);
- @q = qw< { ( [ >;
+ @q = qw< { ( [ >;
@is_opening_token{@q} = (1) x scalar(@q);
- @q = qw< } ) ] >;
+ @q = qw< } ) ] >;
@is_closing_token{@q} = (1) x scalar(@q);
# Patterns for standardizing matches to block types for regular subs and
my $ws_in_container = sub {
my ($j) = @_;
- my $ws = WS_YES;
+ my $ws = WS_YES;
if ( $j + 1 > $jmax ) { return (WS_NO) }
# Patch to count '-foo' as single token so that
my $rcopy =
copy_token_as_type( $rtoken_vars, 'q', $part1 );
$store_token->($rcopy);
- $token = $part2;
+ $token = $part2;
$rtoken_vars->[_TOKEN_] = $token;
}
$store_token_and_space->(
$rcopy, $rwhitespace_flags->[$KK] == WS_YES
);
- $token = $part2;
+ $token = $part2;
$rtoken_vars->[_TOKEN_] = $token;
# Second part goes without intermediate blank
my $length_to_opening_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_opening_container->{$seqno};
+ my $KK = $K_opening_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
my $length_to_closing_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_closing_container->{$seqno};
+ my $KK = $K_closing_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
# a block is broken if the input line numbers of the braces differ
# we can only cuddle between broken blocks
- my ($seqno) = @_;
+ my ($seqno) = @_;
my $K_opening = $K_opening_container->{$seqno};
return unless ( defined($K_opening) );
my $K_closing = $K_closing_container->{$seqno};
my $length_to_opening_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_opening_container->{$seqno};
+ my $KK = $K_opening_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
my $length_to_closing_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_closing_container->{$seqno};
+ my $KK = $K_closing_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
##my $lentot = $rLL->[$KK]->[_CUMULATIVE_LENGTH_];
return $lentot;
}
}
$rOpts->{'closing-side-comment-prefix'} = $csc_prefix;
- $closing_side_comment_prefix_pattern = $csc_prefix_pattern;
+ $closing_side_comment_prefix_pattern = $csc_prefix_pattern;
return;
}
BEGIN {
my @q;
- @q = qw(sort grep map);
+ @q = qw(sort grep map);
@is_sort_grep_map{@q} = (1) x scalar(@q);
- @q = qw(for foreach);
+ @q = qw(for foreach);
@is_for_foreach{@q} = (1) x scalar(@q);
}
# A label can only be used on the next {
if ( $block_type =~ /:$/ ) { $csc_last_label = "" }
$csc_block_label{$type_sequence} = $csc_last_label;
- $csc_last_label = "";
+ $csc_last_label = "";
if ( $accumulating_text_for_block
&& $levels_to_go[$i] == $leading_block_text_level )
# aligner. Assign qw quotes a value to allow qw opening and closing tokens
# to be treated somewhat like opening and closing tokens for stacking
# tokens by the vertical aligner.
- my ($ii) = @_;
+ my ($ii) = @_;
my $seqno = $type_sequence_to_go[$ii];
if ( $types_to_go[$ii] eq 'q' ) {
my $SEQ_QW = -1;
@is_vertical_alignment_type{@q} = (1) x scalar(@q);
# only align these at end of line
- @q = qw(&& ||);
+ @q = qw(&& ||);
@is_terminal_alignment_type{@q} = (1) x scalar(@q);
# eq and ne were removed from this list to improve alignment chances
sub initialize_bond_strength_hashes {
my @q;
- @q = qw(if unless while until for foreach);
+ @q = qw(if unless while until for foreach);
@is_good_keyword_breakpoint{@q} = (1) x scalar(@q);
- @q = qw(lt gt le ge);
+ @q = qw(lt gt le ge);
@is_lt_gt_le_ge{@q} = (1) x scalar(@q);
#
# The decision about where to break a line depends upon a "bond
$right_bond_strength{'CORE::'} = NO_BREAK;
# breaking AFTER modulus operator is ok:
- @q = qw< % >;
+ @q = qw< % >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.1 * NOMINAL + 0.9 * STRONG ) x scalar(@q);
# Break AFTER weakest math operators + and -
# Make them weaker than * but a bit stronger than '.'
- @q = qw< + - >;
+ @q = qw< + - >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.91 * NOMINAL + 0.09 * WEAK ) x scalar(@q);
# make these a little weaker than nominal so that they get
# favored for end-of-line characters
- @q = qw< != == =~ !~ ~~ !~~ >;
+ @q = qw< != == =~ !~ ~~ !~~ >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.9 * NOMINAL + 0.1 * WEAK ) x scalar(@q);
# break AFTER these
- @q = qw# < > | & >= <= #;
+ @q = qw# < > | & >= <= #;
@left_bond_strength{@q} = (VERY_STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.8 * NOMINAL + 0.2 * WEAK ) x scalar(@q);
elsif ( defined( $bias{$left_key} ) ) {
if ( !$want_break_before{$left_key} ) {
$bias{$left_key} += $delta_bias;
- $bond_str += $bias{$left_key};
+ $bond_str += $bias{$left_key};
}
}
BEGIN {
my @q;
- @q = qw( && || );
+ @q = qw( && || );
@is_amp_amp{@q} = (1) x scalar(@q);
- @q = qw( ? : );
+ @q = qw( ? : );
@is_ternary{@q} = (1) x scalar(@q);
- @q = qw( + - * / );
+ @q = qw( + - * / );
@is_math_op{@q} = (1) x scalar(@q);
- @q = qw( + - );
+ @q = qw( + - );
@is_plus_minus{@q} = (1) x scalar(@q);
- @q = qw( * / );
+ @q = qw( * / );
@is_mult_div{@q} = (1) x scalar(@q);
}
# and the rest of the loop to do the join
if ($skip_Section_3) {
$forced_breakpoint_to_go[$iend_1] = 0;
- $n_best = $n;
+ $n_best = $n;
last;
}
&& $rvertical_tightness_flags->[2] == $cached_seqno )
{
$rvertical_tightness_flags->[3] ||= 1;
- $cached_line_valid ||= 1;
+ $cached_line_valid ||= 1;
}
}
$new_fields[$j] = $current_field;
$new_matching_patterns[$j] = $current_pattern;
- $new_alignments[$j] = $old_line->get_alignment($k);
+ $new_alignments[$j] = $old_line->get_alignment($k);
$maximum_field_index = $j;
$old_line->set_alignments(@new_alignments);
unshift( @patterns, @{$rpatterns_old}[ 0 .. $jquestion ] );
# insert appropriate number of empty fields
- $jadd = $jquestion + 1;
+ $jadd = $jquestion + 1;
$fields[0] = $pad . $fields[0];
splice( @fields, 0, 0, ('') x $jadd ) if $jadd;
}
my $maximum_field_index = $old_line->get_jmax();
# flush if this line has too many fields
+ my $GoToLoc = 1;
if ( $jmax > $maximum_field_index ) { goto NO_MATCH }
# flush if adding this line would make a non-monotonic field count
)
)
{
+ $GoToLoc = 2;
goto NO_MATCH;
}
# lists always match ...
# unless they would align any '=>'s with ','s
+ $GoToLoc = 3;
goto NO_MATCH
if ( $old_tok =~ /^=>/ && $new_tok =~ /^,/
|| $new_tok =~ /^=>/ && $old_tok =~ /^,/ );
last;
}
+ $GoToLoc = 4;
goto NO_MATCH;
}
if ( $alignment_token eq ',' ) {
# do not align commas unless they are in named containers
+ $GoToLoc = 5;
goto NO_MATCH unless ( $new_tok =~ /[A-Za-z]/ );
}
# But we can allow a match if the parens don't
# require any padding.
+ $GoToLoc = 6;
if ( $pad != 0 ) { goto NO_MATCH }
}
substr( $old_rpatterns->[$j], 0, 1 ) ne
substr( $rpatterns->[$j], 0, 1 ) )
{
+ $GoToLoc = 7;
goto NO_MATCH;
}
if ( $maximum_field_index > $jmax ) {
# Exception: suspend this rule to allow last lines to join
+ $GoToLoc = 8;
if ( $pad > 0 ) { goto NO_MATCH; }
}
} ## end for my $j ( 0 .. $jlimit)
##########################################################
my $comment = $rfields->[$jmax];
+ $GoToLoc = 9;
goto NO_MATCH if ($comment);
# Corrected loop
return;
NO_MATCH:
+
+ #print "no match from $GoToLoc\n";
##print "no match jmax=$jmax max=$maximum_field_index $group_list_type lines=$maximum_line_index token=$old_rtokens->[0]\n";
# Make one last effort to retain a match of certain statements
my $group_list_type = $group_lines[0]->get_list_type();
- # See if these two lines have leading equals type tokens
- my $rtokens = $group_lines[0]->get_rtokens();
- my $leading_equals = $rtokens->[0] =~ /=/;
+ # See if these two lines have leading equals type tokens which can be
+ # aligned without creating a big gap. These two below are an example that
+ # have a large gap and will not be aligned:
+ # local (@pieces) = split( /\./, $filename, 2 );
+ # local ($just_dir_and_base) = $pieces[0];
+ my $good_leading_equals;
+ my $rtokens = $group_lines[0]->get_rtokens();
+ if ( $rtokens->[0] =~ /=/ ) {
+ my $rfields0 = $group_lines[0]->get_rfields();
+ my $rfields1 = $group_lines[1]->get_rfields();
+ my $len0 = length( $rfields0->[0] );
+ my $len1 = length( $rfields1->[0] );
+ my $gap = abs( $len0 - $len1 );
+
+ # put a limit on the maximum gap we will allow here
+ $good_leading_equals = ( $gap > 8 ) ? 0 : 1;
+ }
my $do_not_align = (
# always align lists
!$group_list_type
- # always align lines with leading equality operators
- && !$leading_equals
-
&& (
- # don't align if it was marked as a 'marginal" match
+ # don't align if it was marked as a 'marginal" match.
$marginal_match
- # don't align two lines with big gap
|| $group_maximum_gap > 12
- # don't align lines with differing number of alignment tokens
- || ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen )
+ # don't align lines with differing number of alignment tokens,
+ # unless the first common alignment is an equals
+ || ( ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen )
+ && !$good_leading_equals )
)
);
# This script will recombine the perltidy binary script and all of its modules
# into a single, monolithic script. I use it for making a temporary "sandbox"
-# for debugging.
+# for debugging.
# This is also useful for making a copy of previous versions for parallel
-# debugging.
+# debugging sessions.
# usage:
# perl pm2pl
# Run this from the perltidy main installation directory. It reads
# bin/perltidy and lib/*.pm and writes a file 'perltidy-VERSION.pl' in the
-# current directory.
+# current directory.
# This should work for a system with File::Spec,
# and for older Windows/Unix systems without File::Spec.
-my $script = 'bin/perltidy';
+my $script = 'bin/perltidy';
my @modules = qw(
lib/Perl/Tidy.pm
lib/Perl/Tidy/Debugger.pm
}
}
-my $VERSION=get_version("lib/Perl/Tidy.pm");
+my $VERSION = get_version("lib/Perl/Tidy.pm");
my $outfile = "perltidy-$VERSION.pl";
open OUTFILE, "> $outfile" or die "can't open file '$outfile' : $!\n";
-print "Creating file '$outfile' ....\n ";
+print "Creating standalone formatter script '$outfile' ....\n ";
# first, open the script and copy the first (hash-bang) line
# (Note: forward slashes in file names here will work in Windows)
my $hash_bang = <SCRIPT>;
print OUTFILE $hash_bang;
-# then copy all modules
+# then copy all modules
foreach my $module (@modules) {
open PM, "< $module" or die "can't open my module file '$module' : $!\n";
while (<PM>) {
print OUTFILE unless $_ =~ /^use Perl::Tidy/;
}
close SCRIPT;
-close OUTPUT;
+close OUTFILE;
chmod 0755, $outfile;
-print "...Done...\n";
-my $testfile = "Makefile.PL";
-if ( -e $testfile ) {
- print <<EOM;
+my $testfile = "somefile.pl";
+print <<EOM;
-You can now run perltidy.pl
-For a quick test, try reformatting $testfile with the following command:
-
- perl perltidy.pl -lp $testfile
-
-and then compare the output in $testfile.tdy with the original file
-EOM
-}
-else {
- $testfile = "somefile";
- print <<EOM;
-
-You can now run perltidy to reformat any perl script.
+You can now run $outfile to reformat perl scripts.
For example, the following command:
- perl perltidy $testfile
+ perl $outfile $testfile
will produce the output file $testfile.tdy
EOM
-}
+
sub get_version {
my ($file) = @_;
my $fh;
if ( $line =~
/^((our)?\s*\$VERSION\s*=\s*\'?) ([^'#]+) (\'?) \s* ;/x )
{
- $VERSION = $3;
+ $VERSION = $3;
last;
}
}
--- /dev/null
+# big gap; do not align the '='
+@_ = qw(sort grep map do eval);
+@is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
--- /dev/null
+# a marginal two-line match: do not align
+$w[$i] = $t;
+$t = 1000000;
--- /dev/null
+# do not align these two (large gap)
+local (@pieces) = split( /\./, $filename, 2 );
+local ($just_dir_and_base) = $pieces[0];
my $type = shift || "o";
- my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
- my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
+ my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
+ my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
--- /dev/null
+# big gap; do not align the '='
+@_ = qw(sort grep map do eval);
+@is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
--- /dev/null
+# a marginal two-line match: do not align
+$w[$i] = $t;
+$t = 1000000;
--- /dev/null
+# do not align these two (large gap)
+local (@pieces) = split( /\./, $filename, 2 );
+local ($just_dir_and_base) = $pieces[0];
my $a = ${^WARNING_BITS};
@{^HOWDY_PARDNER} = ( 101, 102 );
-${^W} = 1;
+${^W} = 1;
$bb[$^]] = "bubba";
$l[$i] = $u;
chomp( $l[$i] );
$w[$i] = $t;
- $t = 1000000;
+ $t = 1000000;
}
else { $l[$i] = $q[$z]; $w[$i] = $p[$z]; $z++; }
print $l[$i], "\t", $w[$i], "\r\n";
../snippets13.t rt127633.rt127633
../snippets13.t align14.def
../snippets13.t align15.def
+../snippets13.t align16.def
+../snippets13.t break5.def
+../snippets13.t align19.def
+../snippets13.t align20.def
../snippets2.t angle.def
../snippets2.t arrows1.def
../snippets2.t arrows2.def
../snippets9.t rt98902.def
../snippets9.t rt98902.rt98902
../snippets9.t rt99961.def
-../snippets13.t align16.def
-../snippets13.t break5.def
+../snippets13.t align21.def
$l[$i] = $u;
chomp( $l[$i] );
$w[$i] = $t;
- $t = 1000000;
+ $t = 1000000;
}
else { $l[$i] = $q[$z]; $w[$i] = $p[$z]; $z++; }
print $l[$i], "\t", $w[$i], "\r\n";
#8 align15.def
#9 align16.def
#10 break5.def
+#11 align19.def
+#12 align20.def
+#13 align21.def
# To locate test #13 you can search for its name or the string '#13'
SPIT => sub { shift },
};
+----------
+
+ 'align19' => <<'----------',
+# big gap; do not align the '='
+@_ = qw(sort grep map do eval);
+@is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
+----------
+
+ 'align20' => <<'----------',
+# a marginal two-line match: do not align
+$w[$i] = $t;
+$t = 1000000;
+----------
+
+ 'align21' => <<'----------',
+# do not align these two (large gap)
+local (@pieces) = split( /\./, $filename, 2 );
+local ($just_dir_and_base) = $pieces[0];
----------
'break5' => <<'----------',
params => "def",
expect => <<'#3...........',
my $type = shift || "o";
- my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
- my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
+ my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
+ my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
#3...........
},
: "\n$type$pod2.html\#" . $value . "\">$text<\/A>\n";
#10...........
},
+
+ 'align19.def' => {
+ source => "align19",
+ params => "def",
+ expect => <<'#11...........',
+# big gap; do not align the '='
+@_ = qw(sort grep map do eval);
+@is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
+#11...........
+ },
+
+ 'align20.def' => {
+ source => "align20",
+ params => "def",
+ expect => <<'#12...........',
+# a marginal two-line match: do not align
+$w[$i] = $t;
+$t = 1000000;
+#12...........
+ },
+
+ 'align21.def' => {
+ source => "align21",
+ params => "def",
+ expect => <<'#13...........',
+# do not align these two (large gap)
+local (@pieces) = split( /\./, $filename, 2 );
+local ($just_dir_and_base) = $pieces[0];
+#13...........
+ },
};
my $ntests = 0 + keys %{$rtests};
expect => <<'#18...........',
my $a = ${^WARNING_BITS};
@{^HOWDY_PARDNER} = ( 101, 102 );
-${^W} = 1;
+${^W} = 1;
$bb[$^]] = "bubba";
#18...........
},