3 -Added -fpsc option (--fixed-position-side-comment). Thanks to Ueli Hugenschmidt.
4 For example -fpsc=40 tells perltidy to put side comments in column 40
7 -Added -bbao and -baao options (--break-before-all-operators and
8 --break-after-all-operators) to simplify command lines and configuration
9 files. These define an initial preference for breaking at operators which can
10 be modified with -wba and -wbb flags. For example to break before all operators
11 except an = one could use --bbao -wba='=' rather than listing every
12 single perl operator (except =) on a -wbb flag.
14 -Added -kis option (--keep-interior-semicolons). Use the B<-kis> flag
15 to prevent breaking at a semicolon if there was no break there in the
16 input flag. To illustrate, consider the following input lines:
18 dbmclose(%verb_delim); undef %verb_delim;
19 dbmclose(%expanded); undef %expanded;
20 dbmclose(%global); undef %global;
22 Normally these would be broken into six lines, but
25 dbmclose(%verb_delim); undef %verb_delim;
26 dbmclose(%expanded); undef %expanded;
27 dbmclose(%global); undef %global;
29 -Improved formatting of complex ternary statements, with indentation
32 return defined( $cw->{Selected} )
34 ? @{ $cw->{Selected} }
39 return defined( $cw->{Selected} )
41 ? @{ $cw->{Selected} }
45 -Text following un-parenthesized if/unless/while/until statements get a
46 full level of indentation. Suggested by Jeff Armstorng and others.
48 return $ship->chargeWeapons("phaser-canon")
49 if $encounter->description eq 'klingon'
50 and $ship->firepower >= $encounter->firepower
51 and $location->status ne 'neutral';
53 return $ship->chargeWeapons("phaser-canon")
54 if $encounter->description eq 'klingon'
55 and $ship->firepower >= $encounter->firepower
56 and $location->status ne 'neutral';
59 -Fixed bug where #line directives were being indented. Thanks to
63 -Fixed problem where an extra blank line was added after an =cut when either
64 (a) the =cut started (not stopped) a POD section, or (b) -mbl > 1.
65 Thanks to J. Robert Ray and Bill Moseley.
68 -ole (--output-line-ending) and -ple (--preserve-line-endings) should
69 now work on all systems rather than just unix systems. Thanks to Dan
72 -Fixed problem of a warning issued for multiple subs for BEGIN subs
73 and other control subs. Thanks to Heiko Eissfeldt.
75 -Fixed problem where no space was introduced between a keyword or
76 bareword and a colon, such as:
78 ( ref($result) eq 'HASH' && !%$result ) ? undef: $result;
82 -Added a utility program 'break_long_quotes.pl' to the examples directory of
83 the distribution. It breaks long quoted strings into a chain of concatenated
84 sub strings no longer than a selected length. Suggested by Michael Renner as
85 a perltidy feature but was judged to be best done in a separate program.
87 -Updated docs to remove extra < and >= from list of tokens
88 after which breaks are made by default. Thanks to Bob Kleemann.
90 -Removed improper uses of $_ to avoid conflicts with external calls, giving
91 error message similar to:
92 Modification of a read-only value attempted at
93 /usr/share/perl5/Perl/Tidy.pm line 6907.
94 Thanks to Michael Renner.
96 -Fixed problem when errorfile was not a plain filename or filehandle
97 in a call to Tidy.pm. The call
98 perltidy(source => \$input, destination => \$output, errorfile => \$err);
99 gave the following error message:
100 Not a GLOB reference at /usr/share/perl5/Perl/Tidy.pm line 3827.
101 Thanks to Michael Renner and Phillipe Bruhat.
103 -Fixed problem where -sot would not stack an opening token followed by
104 a side comment. Thanks to Jens Schicke.
106 -improved breakpoints in complex math and other long statements. Example:
109 log($n) + 0.577215664901532 + ( 1 / ( 2 * $n ) ) -
110 ( 1 / ( 12 * ( $n**2 ) ) ) + ( 1 / ( 120 * ( $n**4 ) ) );
113 log($n) + 0.577215664901532 +
115 ( 1 / ( 12 * ( $n**2 ) ) ) +
116 ( 1 / ( 120 * ( $n**4 ) ) );
118 -more robust vertical alignment of complex terminal else blocks and ternary
122 -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern
123 replacement text was not recognized. The tokenizer now recursively scans
124 replacement text (but does not reformat it).
126 -improved vertical alignment of terminal else blocks and ternary statements.
127 Thanks to Chris for the suggestion.
130 if ( IsBitmap() ) { return GetBitmap(); }
131 elsif ( IsFiles() ) { return GetFiles(); }
132 else { return GetText(); }
135 if ( IsBitmap() ) { return GetBitmap(); }
136 elsif ( IsFiles() ) { return GetFiles(); }
137 else { return GetText(); }
142 : $opts{"s"} ? 'subject'
143 : $opts{"a"} ? 'author'
149 : $opts{"s"} ? 'subject'
150 : $opts{"a"} ? 'author'
153 -improved indentation of try/catch blocks and other externally defined
154 functions accepting a block argument. Thanks to jae.
156 -Added support for Perl 5.10 features say and smartmatch.
158 -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters
159 suggested in Damian Conway's "Perl Best Practices". -pbp is the same as:
161 -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
162 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < =
163 **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
165 Please note that the -st here restricts input to standard input; use
166 -nst if necessary to override.
168 -Eliminated some needless breaks at equals signs in -lp indentation.
172 Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
173 TOP + $y * (BOTTOM - TOP) / SIZE);
175 $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
176 TOP + $y * (BOTTOM - TOP) / SIZE);
178 A break at an equals is sometimes useful for preventing complex statements
179 from hitting the line length limit. The decision to do this was
180 over-eager in some cases and has been improved. Thanks to Royce Reece.
182 -qw quotes contained in braces, square brackets, and parens are being
183 treated more like those containers as far as stacking of tokens. Also
184 stack of closing tokens ending ');' will outdent to where the ');' would
185 have outdented if the closing stack is matched with a similar opening stack.
187 OLD: perltidy -soc -sct
188 __PACKAGE__->load_components(
194 NEW: perltidy -soc -sct
195 __PACKAGE__->load_components( qw(
199 Thanks to Aran Deltac
201 -Eliminated some undesirable or marginally desirable vertical alignments.
202 These include terminal colons, opening braces, and equals, and particularly
203 when just two lines would be aligned.
206 my $accurate_timestamps = $Stamps{lnk};
210 my $accurate_timestamps = $Stamps{lnk};
213 -Corrected a problem with -mangle in which a space would be removed
214 between a keyword and variable beginning with ::.
217 -Attribute argument lists are now correctly treated as quoted strings
218 and not formatted. This is the most important update in this version.
219 Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup.
221 -Updated to recognize the defined or operator, //, to be released in Perl 10.
222 Thanks to Sebastien Aperghis-Tramoni.
224 -A useful utility perltidyrc_dump.pl is included in the examples section. It
225 will read any perltidyrc file and write it back out in a standard format
226 (though comments are lost).
228 -Added option to have perltidy read and return a hash with the contents of a
229 perltidyrc file. This may be used by Leif Eriksen's tidyview code. This
230 feature is used by the demonstration program 'perltidyrc_dump.pl' in the
233 -Improved error checking in perltidyrc files. Unknown bare words were not
236 -The --dump-options parameter now dumps parameters in the format required by a
239 -V-Strings with underscores are now recognized.
240 For example: $v = v1.2_3;
242 -cti=3 option added which gives one extra indentation level to closing
243 tokens always. This provides more predictable closing token placement
244 than cti=2. If you are using cti=2 you might want to try cti=3.
246 -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>.
248 -New parameters -fs, -fsb, -fse added to allow sections of code between #<<<
249 and #>>> to be passed through verbatim. This is enabled by default and turned
250 off by -nfs. Flags -fsb and -fse allow other beginning and ending markers.
251 Thanks to Wolfgang Werner and Marion Berryman for suggesting this.
253 -added flag -skp to put a space between all Perl keywords and following paren.
254 The default is to only do this for certain keywords. Suggested by
257 -added flag -sfp to put a space between a function name and following paren.
258 The default is not to do this. Suggested by H.Merijn Brand.
260 -Added patch to avoid breaking GetOpt::Long::Configure set by calling program.
261 Thanks to Philippe Bruhat.
263 -An error was fixed in which certain parameters in a .perltidyrc file given
264 without the equals sign were not recognized. That is,
265 '--brace-tightness 0' gave an error but '--brace-tightness=0' worked
266 ok. Thanks to Zac Hansen.
268 -An error preventing the -nwrs flag from working was corrected. Thanks to
271 -Corrected some alignment problems with entab option.
273 -A bug with the combination of -lp and -extrude was fixed (though this
274 combination doesn't really make sense). The bug was that a line with
275 a single zero would be dropped. Thanks to Cameron Hayne.
277 -Updated Windows detection code to avoid an undefined variable.
278 Thanks to Joe Yates and Russ Jones.
280 -Improved formatting for short trailing statements following a closing paren.
281 Thanks to Joe Matarazzo.
283 -The handling of the -icb (indent closing block braces) flag has been changed
284 slightly to provide more consistent and predictable formatting of complex
285 structures. Instead of giving a closing block brace the indentation of the
286 previous line, it is now given one extra indentation level. The two methods
287 give the same result if the previous line was a complete statement, as in this
296 The change also fixes a problem with empty blocks such as:
306 -A problem with -icb was fixed in which a closing brace was misplaced when
307 it followed a quote which spanned multiple lines.
309 -Some improved breakpoints for -wba='&& || and or'
311 -Fixed problem with misaligned cuddled else in complex statements
312 when the -bar flag was also used. Thanks to Alex and Royce Reese.
314 -Corrected documentation to show that --outdent-long-comments is the default.
317 -New flag -otr (opening-token-right) is similar to -bar (braces-always-right)
318 but applies to non-structural opening tokens.
320 -new flags -sot (stack-opening-token), -sct (stack-closing-token).
324 -The default has been changed to not do syntax checking with perl.
325 Use -syn if you want it. Perltidy is very robust now, and the -syn
326 flag now causes more problems than it's worth because of BEGIN blocks
327 (which get executed with perl -c). For example, perltidy will never
328 return when trying to beautify this code if -syn is used:
330 BEGIN { 1 while { }; }
332 Although this is an obvious error, perltidy is often run on untested
333 code which is more likely to have this sort of problem. A more subtle
336 BEGIN { use FindBin; }
338 which may hang on some systems using -syn if a shared file system is
341 -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item).
342 In most cases it looks better. To recover the previous format, use
345 -Added flags -cti=n for finer control of closing token indentation.
346 -cti = 0 no extra indentation (default; same as -nicp)
347 -cti = 1 enough indentation so that the closing token
348 aligns with its opening token.
349 -cti = 2 one extra indentation level if the line has the form
350 ); ]; or }; (same as -icp).
352 The new option -cti=1 works well with -lp:
356 # perltidy -lp -cti=1
358 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
359 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
362 # perltidy -lp -cti=2
364 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
365 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
367 This is backwards compatible with -icp. See revised manual for
368 details. Suggested by Mike Pennington.
370 -Added flag '--preserve-line-endings' or '-ple' to cause the output
371 line ending to be the same as in the input file, for unix, dos,
372 or mac line endings. Only works under unix. Suggested by
375 -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win,
376 unix, or mac. Only works under unix.
378 -Files with Mac line endings should now be handled properly under unix
379 and dos without being passed through a converter.
381 -You may now include 'and', 'or', and 'xor' in the list following
382 '--want-break-after' to get line breaks after those keywords rather than
383 before them. Suggested by Rainer Hochschild.
385 -Corrected problem with command line option for -vtc=n and -vt=n. The
386 equals sign was being eaten up by the Windows shell so perltidy didn't
390 -Corrected cause of warning message with recent versions of Perl:
391 "Possible precedence problem on bitwise & operator at ..."
394 -fixed bug with -html with '=for pod2html' sections, in which code/pod
395 output order was incorrect. Thanks to Tassilo von Parseval.
397 -fixed bug when the -html flag is used, in which the following error
398 message, plus others, appear:
399 did not see <body> in pod2html output
400 This was caused by a change in the format of html output by pod2html
401 VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval.
403 -Fixed bug where an __END__ statement would be mistaken for a label
404 if it is immediately followed by a line with a leading colon. Thanks
407 -Implemented guessing logic for brace types when it is ambiguous. This
408 has been on the TODO list a long time. Thanks to Boris Zentner for
411 -Long options may now be negated either as '--nolong-option'
412 or '--no-long-option'. Thanks to Philip Newton for the suggestion.
414 -added flag --html-entities or -hent which controls the use of
415 Html::Entities for html formatting. Use --nohtml-entities or -nhent to
416 prevent the use of Html::Entities to encode special symbols. The
417 default is -hent. Html::Entities when formatting perl text to escape
418 special symbols. This may or may not be the right thing to do,
419 depending on browser/language combinations. Thanks to Burak Gursoy for
422 -Bareword strings with leading '-', like, '-foo' now count as 1 token
423 for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo}
424 are now all treated similarly. Thus, by default, OLD: $a{ -foo } will
425 now be NEW: $a{-foo}. Suggested by Mark Olesen.
427 -added 2 new flags to control spaces between keywords and opening parens:
428 -sak=s or --space-after-keyword=s, and
429 -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords.
431 The new default list of keywords which get a space is:
433 "my local our and or eq ne if else elsif until unless while for foreach
434 return switch case given when"
436 Use -sak=s and -nsak=s to add and remove keywords from this list,
439 Explanation: Stephen Hildrey noted that perltidy was being inconsistent
440 in placing spaces between keywords and opening parens, and sent a patch
441 to give user control over this. The above list was selected as being
442 a reasonable default keyword list. Previously, perltidy
443 had a hardwired list which also included these keywords:
445 push pop shift unshift join split die
447 but did not have 'our'. Example: if you prefer to make perltidy behave
448 exactly as before, you can include the following two lines in your
451 -sak="push pop local shift unshift join split die"
454 -Corrected html error in .toc file when -frm -html is used (extra ");
455 browsers were tolerant of it.
457 -Improved alignment of chains of binary and ?/: operators. Example:
471 -improved breakpoint choices involving '->'
473 -Corrected tokenization of things like ${#} or ${©}. For example,
474 ${©} is valid, but ${© } is a syntax error.
476 -Corrected minor tokenization errors with indirect object notation.
477 For example, 'new A::()' works now.
479 -Minor tokenization improvements; all perl code distributed with perl 5.8
480 seems to be parsed correctly except for one instance (lextest.t)
484 -Implemented scalar attributes. Thanks to Sean Tobin for noting this.
486 -Fixed glitch introduced in previous release where -pre option
487 was not outputting a leading html <pre> tag.
489 -Numerous minor improvements in vertical alignment, including the following:
491 -Improved alignment of opening braces in many cases. Needed for improved
492 switch/case formatting, and also suggested by Mark Olesen for sort/map/grep
493 formatting. For example:
498 sort { $a->[1] <=> $b->[1] }
499 map { [ $_, -M ] } @filenames;
504 sort { $a->[1] <=> $b->[1] }
505 map { [ $_, -M ] } @filenames;
507 -Eliminated alignments across unrelated statements. Example:
509 $borrowerinfo->configure( -state => 'disabled' );
510 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
513 $borrowerinfo->configure( -state => 'disabled' );
514 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
516 Thanks to Mark Olesen for suggesting this.
518 -Improved alignement of '='s in certain cases.
519 Thanks to Norbert Gruener for sending an example.
521 -Outdent-long-comments (-olc) has been re-instated as a default, since
522 it works much better now. Use -nolc if you want to prevent it.
524 -Added check for 'perltidy file.pl -o file.pl', which causes file.pl
525 to be lost. (The -b option should be used instead). Thanks to mreister
526 for reporting this problem.
529 -Switch/case or given/when syntax is now recognized. Its vertical alignment
530 is not great yet, but it parses ok. The words 'switch', 'case', 'given',
531 and 'when' are now treated as keywords. If this causes trouble with older
532 code, we could introduce a switch to deactivate it. Thanks to Stan Brown
533 and Jochen Schneider for recommending this.
535 -Corrected error parsing sub attributes with call parameters.
536 Thanks to Marc Kerr for catching this.
538 -Sub prototypes no longer need to be on the same line as sub names.
540 -a new flag -frm or --frames will cause html output to be in a
541 frame, with table of contents in the left panel and formatted source
542 in the right panel. Try 'perltidy -html -frm somemodule.pm' for example.
544 -The new default for -html formatting is to pass the pod through Pod::Html.
545 The result is syntax colored code within your pod documents. This can be
546 deactivated with -npod. Thanks to those who have written to discuss this,
547 particularly Mark Olesen and Hugh Myers.
549 -the -olc (--outdent-long-comments) option works much better. It now outdents
550 groups of consecutive comments together, and by just the amount needed to
551 avoid having any one line exceeding the maximum line length.
553 -block comments are now trimmed of trailing whitespace.
555 -if a directory specified with -opath does not exist, it will be created.
557 -a table of contents to packages and subs is output when -html is used.
558 Use -ntoc to prevent this.
560 -fixed an unusual bug in which a 'for' statement following a 'format'
561 statement was not correctly tokenized. Thanks to Boris Zentner for
564 -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray.
565 There were some speed issues. Suggested by Joerg Walter.
567 -The treatment of quoted wildcards (file globs) is now system-independent.
572 would match box.pl, box.pm, brinx.pm under any operating system. Of
573 course, anything unquoted will be subject to expansion by any shell.
575 -default color for keywords under -html changed from
576 SaddleBrown (#8B4513) to magenta4 (#8B008B).
578 -fixed an arg parsing glitch in which something like:
580 would trigger the help message and exit, rather than operate on the
584 -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to
585 overwrite the original file with the tidied output file. The original
586 file will be saved with a '.bak' extension (which can be changed with
587 -bext=s). Thanks to Rudi Farkas for the suggestion.
589 -An index to all subs is included at the top of -html output, unless
590 only the <pre> section is written.
592 -Anchor lines of the form <a name="mysub"></a> are now inserted at key points
593 in html output, such as before sub definitions, for the convenience of
594 postprocessing scripts. Suggested by Howard Owen.
596 -The cuddled-else (-ce) flag now also makes cuddled continues, like
599 while ( ( $pack, $file, $line ) = caller( $i++ ) ) {
605 Suggested by Simon Perreault.
607 -Fixed bug in which an extra blank line was added before an =head or
608 similar pod line after an __END__ or __DATA__ line each time
609 perltidy was run. Also, an extra blank was being added after
610 a terminal =cut. Thanks to Mike Birdsall for reporting this.
613 -Fixed bug in which space was inserted in a hyphenated hash key:
614 my $val = $myhash{USER-NAME};
616 my $val = $myhash{USER -NAME};
617 Thanks to an anonymous bug reporter at sourceforge.
619 -Fixed problem with the '-io' ('--indent-only') where all lines
620 were double spaced. Thanks to Nick Andrew for reporting this bug.
622 -Fixed tokenization error in which something like '-e1' was
625 -Corrected a rare problem involving older perl versions, in which
626 a line break before a bareword caused problems with 'use strict'.
627 Thanks to Wolfgang Weisselberg for noting this.
629 -More syntax error checking added.
631 -Outdenting labels (-ola) has been made the default, in order to follow the
632 perlstyle guidelines better. It's probably a good idea in general, but
633 if you do not want this, use -nola in your .perltidyrc file.
635 -Updated rules for padding logical expressions to include more cases.
636 Thanks to Wolfgang Weisselberg for helpful discussions.
638 -Added new flag -osbc (--outdent-static-block-comments) which will
639 outdent static block comments by 2 spaces (or whatever -ci equals).
640 Requested by Jon Robison.
643 -Corrected a bug, introduced in the previous release, in which some
644 closing side comments (-csc) could have incorrect text. This is
645 annoying but will be correct the next time perltidy is run with -csc.
647 -Implemented XHTML patch submitted by Ville Skyttä.
649 -Fixed bug where whitespace was being removed between 'Bar' and '()'
650 in a use statement like:
654 Thanks to Ville Skyttä for reporting this.
656 -Whenever possible, if a logical expression is broken with leading
657 '&&', '||', 'and', or 'or', then the leading line will be padded
658 with additional space to produce alignment. This has been on the
659 todo list for a long time; thanks to Frank Steinhauer for reminding
660 me to do it. Notice the first line after the open parens here:
664 !param("rules.to.$linecount")
665 && !param("rules.from.$linecount")
666 && !param("rules.subject.$linecount")
668 param("rules.fieldname.$linecount")
669 && param("rules.fieldval.$linecount")
671 && !param("rules.size.$linecount")
672 && !param("rules.custom.$linecount")
677 !param("rules.to.$linecount")
678 && !param("rules.from.$linecount")
679 && !param("rules.subject.$linecount")
681 param("rules.fieldname.$linecount")
682 && param("rules.fieldval.$linecount")
684 && !param("rules.size.$linecount")
685 && !param("rules.custom.$linecount")
689 -Corrected a mistokenization of variables for a package with a name
690 equal to a perl keyword. For example:
694 sub qx{print "Hello from my::qx\n";}
696 In this case, the leading 'my' was mistokenized as a keyword, and a
697 space was being place between 'my' and '::'. This has been
698 corrected. Thanks to Martin Sluka for discovering this.
700 -A new flag -bol (--break-at-old-logic-breakpoints)
701 has been added to control whether containers with logical expressions
702 should be broken open. This is the default.
704 -A new flag -bok (--break-at-old-keyword-breakpoints)
705 has been added to follow breaks at old keywords which return lists,
706 such as sort and map. This is the default.
708 -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to
709 follow breaks at trinary (conditional) operators. This is the default.
711 -A new flag -cab=n has been added to control breaks at commas after
712 '=>' tokens. The default is n=1, meaning break unless this breaks
713 open an existing on-line container.
715 -A new flag -boc has been added to allow existing list formatting
716 to be retained. (--break-at-old-comma-breakpoints). See updated manual.
718 -A new flag -iob (--ignore-old-breakpoints) has been added to
719 prevent the locations of old breakpoints from influencing the output
722 -Corrected problem where nested parentheses were not getting full
723 indentation. This has been on the todo list for some time; thanks
724 to Axel Rose for a snippet demonstrating this issue.
726 OLD: inner list is not indented
730 $ret->name, $user->username, $user->host,
731 $user->server->name, $user->nick, "H"
739 $ret->name, $user->username, $user->host,
740 $user->server->name, $user->nick, "H"
744 -Code cleaned up by removing the following unused, undocumented flags.
745 They should not be in any .perltidyrc files because they were just
746 experimental flags which were never documented. Most of them placed
747 artificial limits on spaces, and Wolfgang Weisselberg convinced me that
748 most of them they do more harm than good by causing unexpected results.
750 --maximum-continuation-indentation (-mci)
751 --maximum-whitespace-columns
752 --maximum-space-to-comment (-xsc)
753 --big-space-jump (-bsj)
755 -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and
756 Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's
759 -A new flag -isbc has been added for more control on comments. This flag
760 has the effect that if there is no leading space on the line, then the
761 comment will not be indented, and otherwise it may be. If both -ibc and
762 -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer
765 -A new document 'stylekey.pod' has been created to quickly guide new users
766 through the maze of perltidy style parameters. An html version is
767 on the perltidy web page. Take a look! It should be very helpful.
769 -Parameters for controlling 'vertical tightness' have been added:
770 -vt and -vtc are the main controls, but finer control is provided
771 with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical
772 tightness controls have also been added.
773 See updated manual and also see 'stylekey.pod'. Simple examples:
775 # perltidy -lp -vt=1 -vtc=1
776 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
777 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
779 # perltidy -lp -vt=1 -vtc=0
780 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
781 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
784 -Lists which do not format well in uniform columns are now better
785 identified and formated.
788 return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'},
789 $y + $ruler_info{'size'}, $x - $ruler_info{'size'},
790 $y + $ruler_info{'size'} );
795 $x + $ruler_info{'size'},
796 $y + $ruler_info{'size'},
797 $x - $ruler_info{'size'},
798 $y + $ruler_info{'size'}
802 radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ',
803 'None', 'Default', 'Default', 'Simple', 'Simple');
807 $b->{Init}->get_panel_ref,
808 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple');
810 -Corrected problem where an incorrect html filename was generated for
811 external calls to Tidy.pm module. Fixed incorrect html title when
812 Tidy.pm is called with IO::Scalar or IO::Array source.
814 -Output file permissons are now set as follows. An output script file
815 gets the same permission as the input file, except that owner
816 read/write permission is added (otherwise, perltidy could not be
817 rerun). Html output files use system defaults. Previously chmod 0755
818 was used in all cases. Thanks to Mark Olesen for bringing this up.
820 -Missing semicolons will not be added in multi-line blocks of type
821 sort, map, or grep. This brings perltidy into closer agreement
822 with common practice. Of course, you can still put semicolons
823 there if you like. Thanks to Simon Perreault for a discussion of this.
825 -Most instances of extra semicolons are now deleted. This is
826 particularly important if the -csc option is used. Thanks to Wolfgang
827 Weisselberg for noting this. For example, the following line
828 (produced by 'h2xs' :) has an extra semicolon which will now be
831 BEGIN { plan tests => 1 };
833 -New parameter -csce (--closing-side-comment-else-flag) can be used
834 to control what text is appended to 'else' and 'elsif' blocks.
835 Default is to just add leading 'if' text to an 'else'. See manual.
837 -The -csc option now labels 'else' blocks with additinal information
838 from the opening if statement and elsif statements, if space.
839 Thanks to Wolfgang Weisselberg for suggesting this.
841 -The -csc option will now remove any old closing side comments
842 below the line interval threshold. Thanks to Wolfgang Weisselberg for
845 -The abbreviation feature, which was broken in the previous version,
846 is now fixed. Thanks to Michael Cartmell for noting this.
848 -Vertical alignment is now done for '||=' .. somehow this was
852 -This version uses modules for the first time, and a standard perl
853 Makefile.PL has been supplied. However, perltidy may still be
854 installed as a single script, without modules. See INSTALL for
857 -The man page 'perl2web' has been merged back into the main 'perltidy'
858 man page to simplify installation. So you may remove that man page
859 if you have an older installation.
861 -Added patch from Axel Rose for MacPerl. The patch prompts the user
862 for command line arguments before calling the module
863 Perl::Tidy::perltidy.
865 -Corrected bug with '-bar' which was introduced in the previous
866 version. A closing block brace was being indented. Thanks to
867 Alexandros M Manoussakis for reporting this.
869 -New parameter '--entab-leading-whitespace=n', or '-et=n', has been
870 added for those who prefer tabs. This behaves different from the
871 existing '-t' parameter; see updated man page. Suggested by Mark
874 -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be
875 used to change the flags passed to perltidy in a syntax check.
876 See updated man page. Suggested by Mark Olesen.
878 -New parameter '--output-path=s' or '-opath=s' will cause output
879 files to be placed in directory s. See updated man page. Thanks for
880 Mark Olesen for suggesting this.
882 -New parameter --dump-profile (or -dpro) will dump to
883 standard output information about the search for a
884 configuration file, the name of whatever configuration file
885 is selected, and its contents. This should help debugging
886 config files, especially on different Windows systems.
888 -The -w parameter now notes possible errors of the form:
890 $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace
892 -Corrections added for a leading ':' and for leaving a leading 'tcsh'
893 line untouched. Mark Olesen reported that lines of this form were
894 accepted by perl but not by perltidy:
897 eval 'exec perl -wS $0 "$@"' # shell should exec 'perl'
898 unless 1; # but Perl should skip this one
900 Perl will silently swallow a leading colon on line 1 of a
901 script, and now perltidy will do likewise. For example,
902 this is a valid script, provided that it is the first line,
905 : print "Hello World\n";
907 Also, perltidy will now mark a first line with leading ':' followed by
908 '#' as type SYSTEM (just as a #! line), not to be formatted.
910 -List formatting improved for certain lists with special
911 initial terms, such as occur with 'printf', 'sprintf',
912 'push', 'pack', 'join', 'chmod'. The special initial term is
913 now placed on a line by itself. For example, perltidy -gnu
917 "C4", hex($SourceAddr[0]),
918 hex($SourceAddr[1]), hex($SourceAddr[2]),
924 hex($SourceAddr[0]), hex($SourceAddr[1]),
925 hex($SourceAddr[2]), hex($SourceAddr[3]));
929 @{$$self{states}}, '64', '66', '68',
930 '70', '72', '74', '76',
931 '78', '80', '82', '84',
932 '86', '88', '90', '92',
933 '94', '96', '98', '100',
940 '64', '66', '68', '70', '72', '74', '76',
941 '78', '80', '82', '84', '86', '88', '90',
942 '92', '94', '96', '98', '100', '102', '104'
945 -Lists of complex items, such as matricies, are now detected
946 and displayed with just one item per row:
949 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
950 [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ],
955 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
956 [ 1, tan( deg2rad($a) ), 0 ],
957 [ tan( deg2rad($b) ), 1, 0 ],
961 -The perl syntax check will be turned off for now when input is from
962 standard input or standard output. The reason is that this requires
963 temporary files, which has produced far too many problems during
964 Windows testing. For example, the POSIX module under Windows XP/2000
965 creates temporary names in the root directory, to which only the
966 administrator should have permission to write.
968 -Merged patch sent by Yves Orton to handle appropriate
969 configuration file locations for different Windows varieties
970 (2000, NT, Me, XP, 95, 98).
972 -Added patch to properly handle a for/foreach loop without
973 parens around a list represented as a qw. I didn't know this
974 was possible until Wolfgang Weisselberg pointed it out:
976 foreach my $key qw\Uno Due Tres Quadro\ {
980 But Perl will give a syntax error without the $ variable; ie this will
983 foreach qw\Uno Due Tres Quadro\ {
987 -Merged Windows version detection code sent by Yves Orton. Perltidy
988 now automatically turns off syntax checking for Win 9x/ME versions,
989 and this has solved a lot of robustness problems. These systems
990 cannot reliably handle backtick operators. See man page for
993 -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid
994 output filenames were being created in some cases).
996 -Numerous minor improvements have been made for -lp style indentation.
998 -Long C-style 'for' expressions will be broken after each ';'.
1000 'perltidy -gnu' gives:
1003 for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0
1004 and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()))
1007 for ($status = $db->seq($key, $value, R_CURSOR()) ;
1008 $status == 0 and $key eq $origkey ;
1009 $status = $db->seq($key, $value, R_NEXT()))
1011 -For the -lp option, a single long term within parens
1012 (without commas) now has better alignment. For example,
1016 $self->throw("Must specify a known host, not $location,"
1017 . " possible values ("
1018 . join (",", sort keys %hosts) . ")");
1021 $self->throw("Must specify a known host, not $location,"
1022 . " possible values ("
1023 . join (",", sort keys %hosts) . ")");
1026 -This version is about 20 percent faster than the previous
1027 version as a result of optimization work. The largest gain
1028 came from switching to a dispatch hash table in the
1031 -perltidy -html will check to see if HTML::Entities is
1032 installed, and if so, it will use it to encode unsafe
1035 -Added flag -oext=ext to change the output file extension to
1036 be different from the default ('tdy' or 'html'). For
1039 perltidy -html -oext=htm filename
1041 will produce filename.htm
1043 -Added flag -cscw to issue warnings if a closing side comment would replace
1044 an existing, different side comments. See the man page for details.
1045 Thanks to Peter Masiar for helpful discussions.
1047 -Corrected tokenization error of signed hex/octal/binary numbers. For
1048 example, the first hex number below would have been parsed correctly
1049 but the second one was not:
1050 if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { }
1052 -'**=' was incorrectly tokenized as '**' and '='. This only
1053 caused a problem with the -extrude opton.
1055 -Corrected a divide by zero when -extrude option is used
1057 -The flag -w will now contain all errors reported by 'perl -c' on the
1058 input file, but otherwise they are not reported. The reason is that
1059 perl will report lots of problems and syntax errors which are not of
1060 interest when only a small snippet is being formatted (such as missing
1061 modules and unknown bare words). Perltidy will always report all
1062 significant syntax errors that it finds, such as unbalanced braces,
1063 unless the -q (quiet) flag is set.
1065 -Merged modifications created by Hugh Myers into perltidy.
1066 These include a 'streamhandle' routine which allows perltidy
1067 as a module to operate on input and output arrays and strings
1068 in addition to files. Documentation and new packaging as a
1069 module should be ready early next year; This is an elegant,
1070 powerful update; many thanks to Hugh for contributing it.
1073 -added a tentative patch which tries to keep any existing breakpoints
1074 at lines with leading keywords map,sort,eval,grep. The idea is to
1075 improve formatting of sequences of list operations, as in a schwartzian
1079 my @sorted = map { $_->[0] }
1080 sort { $a->[1] <=> $b->[1] }
1081 map { [ $_, rand ] } @list;
1085 map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
1088 my @sorted = map { $_->[0] }
1089 sort { $a->[1] <=> $b->[1] }
1090 map { [ $_, rand ] } @list;
1092 The new alignment is not as nice as the input, but this is an improvement.
1093 Thanks to Yves Orton for this suggestion.
1095 -modified indentation logic so that a line with leading opening paren,
1096 brace, or square bracket will never have less indentation than the
1097 line with the corresponding opening token. Here's a simple example:
1101 -text => "New Document",
1102 -command => \&new_document
1108 Note how the closing ');' is lined up with the first line, even
1109 though it closes a paren in the 'pack' line. That seems wrong.
1113 -text => "New Document",
1114 -command => \&new_document
1120 This seems nicer: you can up-arrow with an editor and arrive at the
1121 opening 'pack' line.
1123 -corrected minor glitch in which cuddled else (-ce) did not get applied
1124 to an 'unless' block, which should look like this:
1132 Thanks to Jeremy Mates for reporting this.
1134 -The man page has been reorganized to parameters easier to find.
1136 -Added check for multiple definitions of same subroutine. It is easy
1137 to introduce this problem when cutting and pasting. Perl does not
1138 complain about it, but it can lead to disaster.
1140 -The command -pro=filename or -profile=filename may be used to specify a
1141 configuration file which will override the default name of .perltidyrc.
1142 There must not be a space on either side of the '=' sign. I needed
1143 this to be able to easily test perltidy with a variety of different
1144 configuration files.
1146 -Side comment alignment has been improved somewhat across frequent level
1147 changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg
1148 for pointing out this problem. For example:
1151 if ( ref $self ) { # Called as a method
1154 else { # Regular procedure call
1160 if ( ref $self ) { # Called as a method
1163 else { # Regular procedure call
1168 -New command -ssc (--static-side-comment) and related command allows
1169 side comments to be spaced close to preceding character. This is
1170 useful for displaying commented code as side comments.
1172 -New command -csc (--closing-side-comment) and several related
1173 commands allow comments to be added to (and deleted from) any or all
1174 closing block braces. This can be useful if you have to maintain large
1175 programs, especially those that you didn't write. See updated man page.
1176 Thanks to Peter Masiar for this suggestion. For a simple example:
1181 if ( !defined( $_[0] ) ) {
1182 print("Hello, World\n");
1185 print( $_[0], "\n" );
1189 This added '## end sub foo' to the closing brace.
1190 To remove it, perltidy -ncsc.
1192 -New commands -ola, for outdenting labels, and -okw, for outdenting
1193 selected control keywords, were implemented. See the perltidy man
1194 page for details. Thanks to Peter Masiar for this suggestion.
1196 -Hanging side comment change: a comment will not be considered to be a
1197 hanging side comment if there is no leading whitespace on the line.
1198 This should improve the reliability of identifying hanging side comments.
1199 Thanks to Peter Masiar for this suggestion.
1201 -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc
1202 (outdent-long-comments), have been added. The original -oll
1203 (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc.
1204 The new default is just -olq. This was necessary to avoid inconsistency with
1205 the new static block comment option.
1207 -Static block comments: to provide a way to display commented code
1208 better, the convention is used that comments with a leading '##' should
1209 not be formatted as usual. Please see '-sbc' (or '--static-block-comment')
1210 for documentation. It can be deactivated with with -nsbc, but
1211 should not normally be necessary. Thanks to Peter Masiar for this
1214 -Two changes were made to help show structure of complex lists:
1215 (1) breakpoints are forced after every ',' in a list where any of
1216 the list items spans multiple lines, and
1217 (2) List items which span multiple lines now get continuation indentation.
1219 The following example illustrates both of these points. Many thanks to
1220 Wolfgang Weisselberg for this snippet and a discussion of it; this is a
1221 significant formatting improvement. Note how it is easier to see the call
1222 parameters in the NEW version:
1225 assert( __LINE__, ( not defined $check )
1228 or $check eq "old", "Error in parameters",
1229 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1230 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1231 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" );
1236 ( not defined $check )
1240 "Error in parameters",
1241 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1242 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1243 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef"
1246 Another example shows how this helps displaying lists:
1249 %{ $self->{COMPONENTS} } = (
1251 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1253 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1256 The structure is clearer with the added indentation:
1259 %{ $self->{COMPONENTS} } = (
1261 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1263 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1266 -The structure of nested logical expressions is now displayed better.
1267 Thanks to Wolfgang Weisselberg for helpful discussions. For example,
1268 note how the status of the final 'or' is displayed in the following:
1272 and null( $op->sibling )
1273 and $op->ppaddr eq "pp_null"
1274 and class($op) eq "UNOP"
1275 and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/
1276 and $op->first->first->sibling->ppaddr eq "pp_lineseq" )
1277 or ( $op->first->ppaddr eq "pp_lineseq"
1278 and not null $op->first->first->sibling
1279 and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) );
1284 and null( $op->sibling )
1285 and $op->ppaddr eq "pp_null"
1286 and class($op) eq "UNOP"
1289 $op->first->ppaddr =~ /^pp_(and|or)$/
1290 and $op->first->first->sibling->ppaddr eq "pp_lineseq"
1292 or ( $op->first->ppaddr eq "pp_lineseq"
1293 and not null $op->first->first->sibling
1294 and $op->first->first->sibling->ppaddr eq "pp_unstack" )
1298 -A break will always be put before a list item containing a comma-arrow.
1299 This will improve formatting of mixed lists of this form:
1303 'text', 225, 20, -text => 'A Simple Plot',
1311 -text => 'A Simple Plot',
1316 -For convenience, the command -dac (--delete-all-comments) now also
1317 deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod
1318 to a '.TEE' file. Complete control over the treatment of pod and
1319 comments is still possible, as described in the updated help message
1322 -The logic which breaks open 'containers' has been rewritten to be completely
1323 symmetric in the following sense: if a line break is placed after an opening
1324 {, [, or (, then a break will be placed before the corresponding closing
1325 token. Thus, a container either remains closed or is completely cracked
1328 -Improved indentation of parenthesized lists. For example,
1333 atan2( $GPSTempCompLong - $GPSLongitude,
1334 $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 );
1337 $GPSCompCourse = int(
1339 $GPSTempCompLong - $GPSLongitude,
1340 $GPSLatitude - $GPSTempCompLat
1341 ) * 180 / 3.14159265
1344 Further improvements will be made in future releases.
1346 -Some improvements were made in formatting small lists.
1348 -Correspondence between Input and Output line numbers reported in a
1349 .LOG file should now be exact. They were sometimes off due to the size
1350 of intermediate buffers.
1352 -Corrected minor tokenization error in which a ';' in a foreach loop
1353 control was tokenized as a statement termination, which forced a
1366 foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) {
1370 -Corrected a problem with reading config files, in which quote marks were not
1371 stripped. As a result, something like -wba="&& . || " would have the leading
1372 quote attached to the && and not work correctly. A workaround for older
1373 versions is to place a space around all tokens within the quotes, like this:
1376 -Removed any existing space between a label and its ':'
1379 This was necessary because the label and its colon are a single token.
1381 -Corrected tokenization error for the following (highly non-recommended)
1383 $user = @vars[1] / 100;
1385 -Resolved cause of a difference between perltidy under perl v5.6.1 and
1386 5.005_03; the problem was different behavior of \G regex position
1390 -Corrected a bug in which a break was not being made after a full-line
1391 comment within a short eval/sort/map/grep block. A flag was not being
1392 zeroed. The syntax error check catches this. Here is a snippet which
1393 illustrates the bug:
1396 #open Socket to Dispatcher
1397 $sock = &OpenSocket;
1400 The formatter mistakenly thought that it had found the following
1403 eval {#open Socket to Dispatcher$sock = &OpenSocket; };
1405 The patch fixes this. Many thanks to Henry Story for reporting this bug.
1407 -Changes were made to help diagnose and resolve problems in a
1409 (1) processing of command parameters has been into two separate
1410 batches so that any errors in a .perltidyrc file can be localized.
1411 (2) commands --help, --version, and as many of the --dump-xxx
1412 commands are handled immediately, without any command line processing
1414 (3) Perltidy will ignore any commands in the .perltidyrc file which
1415 cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt
1416 -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful
1417 suggestions regarding these updates.
1419 -Syntax check has been reinstated as default for MSWin32 systems. This
1420 way Windows 2000 users will get syntax check by default, which seems
1421 like a better idea, since the number of Win 95/98 systems will be
1422 decreasing over time. Documentation revised to warn Windows 95/98
1423 users about the problem with empty '&1'. Too bad these systems
1424 all report themselves as MSWin32.
1427 -Fixed tokenization error in which a method call of the form
1431 got a space before the '::' like this:
1435 Thanks to David Holden for reporting this.
1437 -Added -html control over pod text, using a new abbreviation 'pd'. See
1438 updated perl2web man page. The default is to use the color of a comment,
1439 but italicized. Old .css style sheets will need a new line for
1440 .pd to use this. The old color was the color of a string, and there
1443 -.css lines are now printed in sorted order.
1445 -Fixed interpolation problem where html files had '$input_file' as title
1446 instead of actual input file name. Thanks to Simon Perreault for finding
1447 this and sending a patch, and also to Tobias Weber.
1449 -Breaks will now have the ':' placed at the start of a line,
1450 one per line by default because this shows logical structure
1451 more clearly. This coding has been completely redone. Some
1452 examples of new ?/: formatting:
1455 wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) :
1456 $dir::cwd->lookup( $_[0] )->path;
1460 ? map( $dir::cwd->lookup($_)->path, @_ )
1461 : $dir::cwd->lookup( $_[0] )->path;
1467 } : { a => 6, b => 8 };
1475 : { a => 6, b => 8 };
1478 $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" :
1479 "Hunk #$self->{hunk} failed--$@");
1482 $self->note($self->{skip}
1483 ? "Hunk #$self->{hunk} ignored at 1.\n"
1484 : "Hunk #$self->{hunk} failed--$@");
1488 $opts{"t"} ? 'title' :
1489 $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title';
1493 $opts{"t"} ? 'title'
1494 : $opts{"s"} ? 'subject'
1495 : $opts{"a"} ? 'author'
1498 You can use -wba=':' to recover the previous default which placed ':'
1499 at the end of a line. Thanks to Michael Cartmell for helpful
1500 discussions and examples.
1502 -Tokenizer updated to do syntax checking for matched ?/: pairs. Also,
1503 the tokenizer now outputs a unique serial number for every balanced
1504 pair of brace types and ?/: pairs. This greatly simplifies the
1507 -Long lines with repeated 'and', 'or', '&&', '||' will now have
1508 one such item per line. For example:
1511 if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x
1512 || ( -e $archive && $opt_r ) )
1514 ( $pAr, $pNames ) = readAr($archive);
1523 || ( -e $archive && $opt_r ) )
1525 ( $pAr, $pNames ) = readAr($archive);
1529 if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x
1530 && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y )
1533 if ( $vp->{X0} + 4 <= $x
1534 && $vp->{X0} + $vp->{W} - 4 >= $x
1535 && $vp->{Y0} + 4 <= $y
1536 && $vp->{Y0} + $vp->{H} - 4 >= $y )
1538 -Long lines with multiple concatenated tokens will have concatenated
1539 terms (see below) placed one per line, except for short items. For
1544 "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:"
1545 . $ib->crc . ": " . $ib->model() . "\n";
1548 $report .= "Device type:"
1549 . $ib->family . " ID:"
1550 . $ib->serial . " CRC:"
1552 . $ib->crc . ": " . "\n";
1554 NOTE: at present 'short' means 8 characters or less. There is a
1555 tentative flag to change this (-scl), but it is undocumented and
1556 is likely to be changed or removed later, so only use it for testing.
1557 In the above example, the tokens " ID:", " CRC:", and "\n" are below
1560 -If a line which is short enough to fit on a single line was
1561 nevertheless broken in the input file at a 'good' location (see below),
1562 perltidy will try to retain a break. For example, the following line
1563 will be formatted as:
1566 or die "Cannot open $file ($!)";
1568 if it was broken in the input file, and like this if not:
1570 open SUM, "<$file" or die "Cannot open $file ($!)";
1572 GOOD: 'good' location means before 'and','or','if','unless','&&','||'
1574 The reason perltidy does not just always break at these points is that if
1575 there are multiple, similar statements, this would preclude alignment. So
1576 rather than check for this, perltidy just tries to follow the input style,
1577 in the hopes that the author made a good choice. Here is an example where
1578 we might not want to break before each 'if':
1580 ($Locale, @Locale) = ($English, @English) if (@English > @Locale);
1581 ($Locale, @Locale) = ($German, @German) if (@German > @Locale);
1582 ($Locale, @Locale) = ($French, @French) if (@French > @Locale);
1583 ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale);
1585 -Added wildcard file expansion for systems with shells which lack this.
1586 Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers
1587 for suggesting this. This uses builtin glob() for now; I may change that.
1589 -Added new flag -sbl which, if specified, overrides the value of -bl
1590 for opening sub braces. This allows formatting of this type:
1596 if (!defined($_[0])) {
1597 print("Hello, World\n");
1603 Requested by Don Alexander.
1605 -Fixed minor parsing error which prevented a space after a $$ variable
1606 (pid) in some cases. Thanks to Michael Cartmell for noting this.
1611 -Improved line break choices 'and' and 'or' to display logic better.
1615 exists $self->{'build_dir'} and push @e,
1616 "Unwrapped into directory $self->{'build_dir'}";
1619 exists $self->{'build_dir'}
1620 and push @e, "Unwrapped into directory $self->{'build_dir'}";
1622 -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains
1623 abbreviation for delete-side-comments; -dsm is new abbreviation for
1626 -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for
1629 -The default for Windows is, for now, not to do a 'perl -c' syntax
1630 check (but -syn will activate it). This is because of problems with
1631 command.com. James Freeman sent me a patch which tries to get around
1632 the problems, and it works in many cases, but testing revealed several
1633 issues that still need to be resolved. So for now, the default is no
1634 syntax check for Windows.
1636 -I added a -T flag when doing perl -c syntax check.
1637 This is because I test it on a large number of scripts from sources
1638 unknown, and who knows what might be hidden in initialization blocks?
1639 Also, deactivated the syntax check if perltidy is run as root. As a
1640 benign example, running the previous version of perltidy on the
1641 following file would cause it to disappear:
1644 print "Bye, bye baby!\n";
1648 The new version will not let that happen.
1650 -I am contemplating (but have not yet implemented) making '-lp' the
1651 default indentation, because it is stable now and may be closer to how
1652 perl is commonly formatted. This could be in the next release. The
1653 reason that '-lp' was not the original default is that the coding for
1654 it was complex and not ready for the initial release of perltidy. If
1655 anyone has any strong feelings about this, I'd like to hear. The
1656 current default could always be recovered with the '-nlp' flag.
1660 - sub definition names are now specially colored, red by default.
1661 The letter 'm' is used to identify them.
1662 - keyword 'sub' now has color of other keywords.
1663 - restored html keyword color to __END__ and __DATA__, which was
1664 accidentally removed in the previous version.
1666 -A new -se (--standard-error-output) flag has been implemented and
1667 documented which causes all errors to be written to standard output
1668 instead of a .ERR file.
1670 -A new -w (--warning-output) flag has been implemented and documented
1671 which causes perltidy to output certain non-critical messages to the
1672 error output file, .ERR. These include complaints about pod usage,
1673 for example. The default is to not include these.
1675 NOTE: This replaces an undocumented -w=0 or --warning-level flag
1676 which was tentatively introduced in the previous version to avoid some
1677 unwanted messages. The new default is the same as the old -w=0, so
1678 that is no longer needed.
1680 -Improved syntax checking and corrected tokenization of functions such
1681 as rand, srand, sqrt, ... These can accept either an operator or a term
1682 to their right. This has been corrected.
1684 -Corrected tokenization of semicolon: testing of the previous update showed
1685 that the semicolon in the following statement was being mis-tokenized. That
1686 did no harm, other than adding an extra blank space, but has been corrected.
1688 for (sort {strcoll($a,$b);} keys %investments) {
1692 -New syntax check: after wasting 5 minutes trying to resolve a syntax
1693 error in which I had an extra terminal ';' in a complex for (;;) statement,
1694 I spent a few more minutes adding a check for this in perltidy so it won't
1697 -The behavior of --break-before-subs (-bbs) and --break-before-blocks
1698 (-bbb) has been modified. Also, a new control parameter,
1699 --long-block-line-count=n (-lbl=n) has been introduced to give more
1700 control on -bbb. This was previously a hardwired value. The reason
1701 for the change is to reduce the number of unwanted blank lines that
1702 perltidy introduces, and make it less erratic. It's annoying to remove
1703 an unwanted blank line and have perltidy put it back. The goal is to
1704 be able to sprinkle a few blank lines in that dense script you
1705 inherited from Bubba. I did a lot of experimenting with different
1706 schemes for introducing blank lines before and after code blocks, and
1707 decided that there is no really good way to do it. But I think the new
1708 scheme is an improvement. You can always deactivate this with -nbbb.
1709 I've been meaning to work on this; thanks to Erik Thaysen for bringing
1712 -The .LOG file is seldom needed, and I get tired of deleting them, so
1713 they will now only be automatically saved if perltidy thinks that it
1714 made an error, which is almost never. You can still force the logfile
1715 to be saved with -log or -g.
1717 -Improved method for computing number of columns in a table. The old
1718 method always tried for an even number. The new method allows odd
1719 numbers when it is obvious that a list is not a hash initialization
1723 $name, $xsargs, $parobjs, $optypes,
1724 $hasp2child, $pmcode, $hdrcode, $inplacecode,
1725 $globalnew, $callcopy
1730 $name, $xsargs, $parobjs, $optypes, $hasp2child,
1731 $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy
1735 -I fiddled with the list threshold adjustment, and some small lists
1736 look better now. Here is the change for one of the lists in test file
1740 ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%",
1741 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%");
1745 "in", "in", "pt", "pt", "pc", "pi",
1746 "mm", "mm", "cm", "cm", "\\hsize", "%",
1747 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"
1750 -Improved -lp formatting at '=' sign. A break was always being added after
1751 the '=' sign in a statement such as this, (to be sure there was enough room
1752 for the parameters):
1757 $biblionumber, $constraint,
1761 The updated version doesn't do this unless the space is really needed:
1763 new: my $fee = CalcReserveFee(
1765 $biblionumber, $constraint,
1769 -I updated the tokenizer to allow $#+ and $#-, which seem to be new to
1770 Perl 5.6. Some experimenting with a recent version of Perl indicated
1771 that it allows these non-alphanumeric '$#' array maximum index
1772 varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#:
1773 seems to be valid in older versions of Perl.
1775 -Fixed a rare formatting problem with -lp (and -gnu) which caused
1776 excessive indentation.
1778 -Many additional syntax checks have been added.
1780 -Revised method for testing here-doc target strings; the following
1781 was causing trouble with a regex test because of the '*' characters:
1785 Perl seems to allow almost anything to be a here doc target, so an
1786 exact string comparison is now used.
1788 -Made update to allow underscores in binary numbers, like '0b1100_0000'.
1790 -Corrected problem with scanning certain module names; a blank space was
1791 being inserted after 'warnings' in the following:
1792 use warnings::register;
1793 The problem was that warnings (and a couple of other key modules) were
1794 being tokenized as keywords. They should have just been identifiers.
1796 -Corrected tokenization of indirect objects after sort, system, and exec,
1797 after testing produced an incorrect error message for the following
1799 print sort $sortsubref @list;
1801 -Corrected minor problem where a line after a format had unwanted
1802 extra continuation indentation.
1804 -Delete-block-comments (and -dac) now retain any leading hash-bang line
1806 -Update for -lp (and -gnu) to not align the leading '=' of a list
1807 with a previous '=', since this interferes with alignment of parameters.
1809 old: my $hireDay = new Date;
1816 new: my $hireDay = new Date;
1823 -Modifications made to display tables more compactly when possible,
1824 without adding lines. For example,
1826 '1', "I", '2', "II", '3', "III", '4', "IV",
1827 '5', "V", '6', "VI", '7', "VII", '8', "VIII",
1830 '1', "I", '2', "II", '3', "III",
1831 '4', "IV", '5', "V", '6', "VI",
1832 '7', "VII", '8', "VIII", '9', "IX"
1834 -Corrected minor bug in which -pt=2 did not keep the right paren tight
1835 around a '++' or '--' token, like this:
1837 for ($i = 0 ; $i < length $key ; $i++ )
1839 The formatting for this should be, and now is:
1841 for ($i = 0 ; $i < length $key ; $i++)
1843 Thanks to Erik Thaysen for noting this.
1845 -Discovered a new bug involving here-docs during testing! See BUGS.html.
1847 -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature).
1848 However, the attributes and prototypes must still be on the same line
1852 -Corrected minor, uncommon bug found during routine testing, in which a
1853 blank got inserted between a function name and its opening paren after
1854 a file test operator, but only in the case that the function had not
1855 been previously seen. Perl uses the existance (or lack thereof) of
1856 the blank to guess if it is a function call. That is,
1857 if (-l pid_filename()) {
1859 if (-l pid_filename ()) {
1860 which is a syntax error if pid_filename has not been seen by perl.
1862 -If the AutoLoader module is used, perltidy will continue formatting
1863 code after seeing an __END__ line. Use -nlal to deactivate this feature.
1864 Likewise, if the SelfLoader module is used, perltidy will continue
1865 formatting code after seeing a __DATA__ line. Use -nlsl to
1866 deactivate this feature. Thanks to Slaven Rezic for this suggestion.
1868 -pod text after __END__ and __DATA__ is now identified by perltidy
1869 so that -dp works correctly. Thanks to Slaven Rezic for this suggestion.
1871 -The first $VERSION line which might be eval'd by MakeMaker
1872 is now passed through unchanged. Use -npvl to deactivate this feature.
1873 Thanks to Manfred Winter for this suggestion.
1875 -Improved indentation of nested parenthesized expressions. Tests have
1876 given favorable results. Thanks to Wolfgang Weisselberg for helpful
1880 -Fixed a very rare problem in which an unwanted semicolon was inserted
1881 due to misidentification of anonymous hash reference curly as a code
1882 block curly. (No instances of this have been reported; I discovered it
1883 during testing). A workaround for older versions of perltidy is to use
1886 -Added -icb (-indent-closing-brace) parameter to indent a brace which
1887 terminates a code block to the same level as the previous line.
1888 Suggested by Andrew Cutler. For example,
1897 -Rewrote error message triggered by an unknown bareword in a print or
1898 printf filehandle position, and added flag -w=0 to prevent issuing this
1899 error message. Suggested by Byron Jones.
1901 -Added modification to align a one-line 'if' block with similar
1902 following 'elsif' one-line blocks, like this:
1903 if ( $something eq "simple" ) { &handle_simple }
1904 elsif ( $something eq "hard" ) { &handle_hard }
1905 (Suggested by Wolfgang Weisselberg).
1908 -Eliminated all constants with leading underscores because perl 5.005_03
1909 does not support that. For example, _SPACES changed to XX_SPACES.
1910 Thanks to kromJx for this update.
1913 -the directory of test files has been moved to a separate distribution
1914 file because it is getting large but is of little interest to most users.
1915 For the current distribution:
1916 perltidy-20010701.tgz contains the source and docs for perltidy
1917 perltidy-20010701-test.tgz contains the test files
1919 -fixed bug where temporary file perltidy.TMPI was not being deleted
1920 when input was from stdin.
1922 -adjusted line break logic to not break after closing brace of an
1923 eval block (suggested by Boris Zentner).
1925 -added flag -gnu (--gnu-style) to give an approximation to the GNU
1926 style as sometimes applied to perl. The programming style in GNU
1927 'automake' was used as a guide in setting the parameters; these
1928 parameters will probably be adjusted over time.
1930 -an empty code block now has one space for emphasis:
1931 if ( $cmd eq "bg_untested" ) {} # old
1932 if ( $cmd eq "bg_untested" ) { } # new
1933 If this bothers anyone, we could create a parameter.
1935 -the -bt (--brace-tightness) parameter has been split into two
1936 parameters to give more control. -bt now applies only to non-BLOCK
1937 braces, while a new parameter -bbt (block-brace-tightness) applies to
1938 curly braces which contain code BLOCKS. The default value is -bbt=0.
1940 -added flag -icp (--indent-closing-paren) which leaves a statment
1941 termination of the form );, };, or ]; indented with the same
1942 indentation as the previous line. For example,
1944 @month_of_year = ( # default, or -nicp
1945 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1949 @month_of_year = ( # -icp
1950 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1954 -Vertical alignment updated to synchronize with tokens &&, ||,
1955 and, or, if, unless. Allowable space before forcing
1956 resynchronization has been increased. (Suggested by Wolfgang
1959 -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold,
1960 and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There
1961 was no way to negate these previously. html documentation updated and
1962 corrected. (Suggested by Wolfgang Weisselberg).
1964 -Some modifications have been made which improve the -lp formatting in
1967 -Perltidy now retains or creates a blank line after an =cut to keep
1968 podchecker happy (Suggested by Manfred H. Winter). This appears to be
1969 a glitch in podchecker, but it was annoying.
1972 -Added -bli flag to give continuation indentation to braces, like this
1976 extra_indentation();
1979 -Corrected an error with the tab (-t) option which caused the last line
1980 of a multi-line quote to receive a leading tab. This error was in
1981 version 2001 06 08 but not 2001 04 06. If you formatted a script
1982 with -t with this version, please check it by running once with the
1983 -chk flag and perltidy will scan for this possible error.
1985 -Corrected an invalid pattern (\R should have been just R), changed
1986 $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected
1987 several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg,
1988 2001-06-12, for catching these errors.
1990 -A '-bar' flag has been added to require braces to always be on the
1991 right, even for multi-line if and foreach statements. For example,
1992 the default formatting of a long if statement would be:
1994 if ($bigwasteofspace1 && $bigwasteofspace2
1995 || $bigwasteofspace3 && $bigwasteofspace4)
2000 With -bar, the formatting is:
2002 if ($bigwasteofspace1 && $bigwasteofspace2
2003 || $bigwasteofspace3 && $bigwasteofspace4) {
2006 Suggested by Eli Fidler 2001-06-11.
2008 -Uploaded perltidy to sourceforge cvs 2001-06-10.
2010 -An '-lp' flag (--line-up-parentheses) has been added which causes lists
2011 to be indented with extra indentation in the manner sometimes
2012 associated with emacs or the GNU suggestions. Thanks to Ian Stuart for
2013 this suggestion and for extensive help in testing it.
2015 -Subroutine call parameter lists are now formatted as other lists.
2016 This should improve formatting of tables being passed via subroutine
2017 calls. This will also cause full indentation ('-i=n, default n= 4) of
2018 continued parameter list lines rather than just the number of spaces
2019 given with -ci=n, default n=2.
2021 -Added support for hanging side comments. Perltidy identifies a hanging
2022 side comment as a comment immediately following a line with a side
2023 comment or another hanging side comment. This should work in most
2024 cases. It can be deactivated with --no-hanging-side-comments (-nhsc).
2025 The manual has been updated to discuss this. Suggested by Brad
2026 Eisenberg some time ago, and finally implemented.
2029 -fixed problem with parsing command parameters containing quoted
2030 strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07).
2032 -added two command line flags, --want-break-after and
2033 --want-break-before, which allow changing whether perltidy
2034 breaks lines before or after any operators. Please see the revised
2035 man pages for details.
2037 -added system-wide configuration file capability.
2038 If perltidy does not find a .perltidyrc command line file in
2039 the current directory, nor in the home directory, it now looks
2040 for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'.
2041 (Suggested by Roger Espel Llima 2001-05-31).
2043 -fixed problem in which spaces were trimmed from lines of a multi-line
2044 quote. (Reported by Roger Espel Llima 2001-05-30). This is an
2045 uncommon situation, but serious, because it could conceivably change
2046 the proper function of a script.
2048 -fixed problem in which a semicolon was incorrectly added within
2049 an anonymous hash. (Reported by A.C. Yardley, 2001-5-23).
2050 (You would know if this happened, because perl would give a syntax
2051 error for the resulting script).
2053 -fixed problem in which an incorrect error message was produced
2054 after a version number on a 'use' line, like this ( Reported
2055 by Andres Kroonmaa, 2001-5-14):
2057 use CGI 2.42 qw(fatalsToBrowser);
2059 Other than the extraneous error message, this bug was harmless.
2062 -fixed serious bug in which the last line of some multi-line quotes or
2063 patterns was given continuation indentation spaces. This may make
2064 a pattern incorrect unless it uses the /x modifier. To find
2065 instances of this error in scripts which have been formatted with
2066 earlier versions of perltidy, run with the -chk flag, which has
2067 been added for this purpose (SLH, 2001-04-05).
2069 ** So, please check previously formatted scripts by running with -chk
2072 -continuation indentation has been reprogrammed to be hierarchical,
2073 which improves deeply nested structures.
2075 -fixed problem with undefined value in list formatting (reported by Michael
2078 -Switched to graphical display of nesting in .LOG files. If an
2079 old format string was "(1 [0 {2", the new string is "{{(". This
2080 is easier to read and also shows the order of nesting.
2082 -added outdenting of cuddled paren structures, like ")->pack(".
2084 -added line break and outdenting of ')->' so that instead of
2087 -text => "perltidy",
2088 -relief => 'ridge')->pack;
2090 the current default is:
2093 -text => "perltidy",
2097 (requested by Michael Langner 2001-03-31; in the future this could
2098 be controlled by a command-line parameter).
2100 -revised list indentation logic, so that lists following an assignment
2101 operator get one full indentation level, rather than just continuation
2102 indentation. Also corrected some minor glitches in the continuation
2105 -Fixed problem with unwanted continuation indentation after a blank line
2106 (reported by Erik Thaysen 2001-03-28):
2108 -minor update to avoid stranding a single '(' on one line
2111 -corrected serious error tokenizing filehandles, in which a sub call
2112 after a print or printf, like this:
2113 print usage() and exit;
2115 print usage () and exit;
2116 Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun
2117 perltidy; it will look for this situation and issue a warning.
2119 -fixed another cuddled-else formatting bug (Reported by Craig Bourne)
2121 -added several diagnostic --dump routines
2123 -added token-level whitespace controls (suggested by Hans Ecke)
2126 -added support for special variables of the form ${^WANT_BITS}
2128 -space added between scalar and left paren in 'for' and 'foreach' loops,
2129 (suggestion by Michael Cartmell):
2131 for $i( 1 .. 20 ) # old
2132 for $i ( 1 .. 20 ) # new
2134 -html now outputs cascading style sheets (thanks to suggestion from
2137 -flags -o and -st now work with -html
2139 -added missing -html documentation for comments (noted by Alex Izvorski)
2141 -support for VMS added (thanks to Michael Cartmell for code patches and
2144 -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive
2145 testing by Michael Cartmell)
2147 -fixed problem where operand may be empty at line 3970
2148 (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen,
2149 Keith Marshall for bug reports)
2151 -fixed -ce bug (cuddled else), where lines like '} else {' were indented
2152 (Thanks to Shawn Stepper and Rick Measham for reporting this)
2155 -fixed undefined value in line 153 (only worked with -I set)
2156 (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others)
2158 -fixed undefined value in line 1069 (filehandle problem with perl versions <
2159 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber)
2162 -Initial announcement at freshmeat.net; started Change Log
2163 (Unfortunately this version was DOA, but it was fixed the next day)