3 -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern
4 replacement text was not recognized. The tokenizer now recursively scans
5 replacement text (but does not reformat it).
7 -Improved vertical alignment of terminal else blocks and ternary statements.
8 Thanks to Chris for the suggestion.
11 if ( IsBitmap() ) { return GetBitmap(); }
12 elsif ( IsFiles() ) { return GetFiles(); }
13 else { return GetText(); }
16 if ( IsBitmap() ) { return GetBitmap(); }
17 elsif ( IsFiles() ) { return GetFiles(); }
18 else { return GetText(); }
23 : $opts{"s"} ? 'subject'
24 : $opts{"a"} ? 'author'
30 : $opts{"s"} ? 'subject'
31 : $opts{"a"} ? 'author'
34 -improved indentation of try/catch blocks and other externally defined
35 functions accepting a block argument. Thanks to jae.
37 -Added support for Perl 5.10 features say and smartmatch.
39 -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters
40 suggested in Damian Conway's "Perl Best Practices". -pbp is the same as:
42 -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
43 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < =
44 **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
46 Please note that the -st here restricts input to standard input; use
47 -nst if necessary to override.
49 -Eliminated some needless breaks at equals signs in -lp indentation.
53 Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
54 TOP + $y * (BOTTOM - TOP) / SIZE);
56 $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
57 TOP + $y * (BOTTOM - TOP) / SIZE);
59 A break at an equals is sometimes useful for preventing complex statements
60 from hitting the line length limit. The decision to do this was
61 over-eager in some cases and has been improved. Thanks to Royce Reece.
63 -qw quotes contained in braces, square brackets, and parens are being
64 treated more like those containers as far as stacking of tokens. Also
65 stack of closing tokens ending ');' will outdent to where the ');' would
66 have outdented if the closing stack is matched with a similar opening stack.
68 OLD: perltidy -soc -sct
69 __PACKAGE__->load_components(
75 NEW: perltidy -soc -sct
76 __PACKAGE__->load_components( qw(
82 -Eliminated some undesirable or marginally desirable vertical alignments.
83 These include terminal colons, opening braces, and equals, and particularly
84 when just two lines would be aligned.
87 my $accurate_timestamps = $Stamps{lnk};
91 my $accurate_timestamps = $Stamps{lnk};
94 -Corrected a problem with -mangle in which a space would be removed
95 between a keyword and variable beginning with ::.
98 -Attribute argument lists are now correctly treated as quoted strings
99 and not formatted. This is the most important update in this version.
100 Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup.
102 -Updated to recognize the defined or operator, //, to be released in Perl 10.
103 Thanks to Sebastien Aperghis-Tramoni.
105 -A useful utility perltidyrc_dump.pl is included in the examples section. It
106 will read any perltidyrc file and write it back out in a standard format
107 (though comments are lost).
109 -Added option to have perltidy read and return a hash with the contents of a
110 perltidyrc file. This may be used by Leif Eriksen's tidyview code. This
111 feature is used by the demonstration program 'perltidyrc_dump.pl' in the
114 -Improved error checking in perltidyrc files. Unknown bare words were not
117 -The --dump-options parameter now dumps parameters in the format required by a
120 -V-Strings with underscores are now recognized.
121 For example: $v = v1.2_3;
123 -cti=3 option added which gives one extra indentation level to closing
124 tokens always. This provides more predictable closing token placement
125 than cti=2. If you are using cti=2 you might want to try cti=3.
127 -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>.
129 -New parameters -fs, -fsb, -fse added to allow sections of code between #<<<
130 and #>>> to be passed through verbatim. This is enabled by default and turned
131 off by -nfs. Flags -fsb and -fse allow other beginning and ending markers.
132 Thanks to Wolfgang Werner and Marion Berryman for suggesting this.
134 -added flag -skp to put a space between all Perl keywords and following paren.
135 The default is to only do this for certain keywords. Suggested by
138 -added flag -sfp to put a space between a function name and following paren.
139 The default is not to do this. Suggested by H.Merijn Brand.
141 -Added patch to avoid breaking GetOpt::Long::Configure set by calling program.
142 Thanks to BOOK at CPAN.
144 -An error was fixed in which certain parameters in a .perltidyrc file given
145 without the equals sign were not recognized. That is,
146 '--brace-tightness 0' gave an error but '--brace-tightness=0' worked
147 ok. Thanks to Zac Hansen.
149 -An error preventing the -nwrs flag from working was corrected. Thanks to
152 -Corrected some alignment problems with entab option.
154 -A bug with the combination of -lp and -extrude was fixed (though this
155 combination doesn't really make sense). The bug was that a line with
156 a single zero would be dropped. Thanks to Cameron Hayne.
158 -Updated Windows detection code to avoid an undefined variable.
159 Thanks to Joe Yates and Russ Jones.
161 -Improved formatting for short trailing statements following a closing paren.
162 Thanks to Joe Matarazzo.
164 -The handling of the -icb (indent closing block braces) flag has been changed
165 slightly to provide more consistent and predictable formatting of complex
166 structures. Instead of giving a closing block brace the indentation of the
167 previous line, it is now given one extra indentation level. The two methods
168 give the same result if the previous line was a complete statement, as in this
177 The change also fixes a problem with empty blocks such as:
187 -A problem with -icb was fixed in which a closing brace was misplaced when
188 it followed a quote which spanned multiple lines.
190 -Some improved breakpoints for -wba='&& || and or'
192 -Fixed problem with misaligned cuddled else in complex statements
193 when the -bar flag was also used. Thanks to Alex and Royce Reese.
195 -Corrected documentation to show that --outdent-long-comments is the default.
198 -New flag -otr (opening-token-right) is similar to -bar (braces-always-right)
199 but applies to non-structural opening tokens.
201 -new flags -sot (stack-opening-token), -sct (stack-closing-token).
205 -The default has been changed to not do syntax checking with perl.
206 Use -syn if you want it. Perltidy is very robust now, and the -syn
207 flag now causes more problems than it's worth because of BEGIN blocks
208 (which get executed with perl -c). For example, perltidy will never
209 return when trying to beautify this code if -syn is used:
211 BEGIN { 1 while { }; }
213 Although this is an obvious error, perltidy is often run on untested
214 code which is more likely to have this sort of problem. A more subtle
217 BEGIN { use FindBin; }
219 which may hang on some systems using -syn if a shared file system is
222 -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item).
223 In most cases it looks better. To recover the previous format, use
226 -Added flags -cti=n for finer control of closing token indentation.
227 -cti = 0 no extra indentation (default; same as -nicp)
228 -cti = 1 enough indentation so that the closing token
229 aligns with its opening token.
230 -cti = 2 one extra indentation level if the line has the form
231 ); ]; or }; (same as -icp).
233 The new option -cti=1 works well with -lp:
237 # perltidy -lp -cti=1
239 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
240 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
243 # perltidy -lp -cti=2
245 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
246 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
248 This is backwards compatible with -icp. See revised manual for
249 details. Suggested by Mike Pennington.
251 -Added flag '--preserve-line-endings' or '-ple' to cause the output
252 line ending to be the same as in the input file, for unix, dos,
253 or mac line endings. Only works under unix. Suggested by
256 -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win,
257 unix, or mac. Only works under unix.
259 -Files with Mac line endings should now be handled properly under unix
260 and dos without being passed through a converter.
262 -You may now include 'and', 'or', and 'xor' in the list following
263 '--want-break-after' to get line breaks after those keywords rather than
264 before them. Suggested by Rainer Hochschild.
266 -Corrected problem with command line option for -vtc=n and -vt=n. The
267 equals sign was being eaten up by the Windows shell so perltidy didn't
271 -Corrected cause of warning message with recent versions of Perl:
272 "Possible precedence problem on bitwise & operator at ..."
275 -fixed bug with -html with '=for pod2html' sections, in which code/pod
276 output order was incorrect. Thanks to Tassilo von Parseval.
278 -fixed bug when the -html flag is used, in which the following error
279 message, plus others, appear:
280 did not see <body> in pod2html output
281 This was caused by a change in the format of html output by pod2html
282 VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval.
284 -Fixed bug where an __END__ statement would be mistaken for a label
285 if it is immediately followed by a line with a leading colon. Thanks
288 -Implemented guessing logic for brace types when it is ambiguous. This
289 has been on the TODO list a long time. Thanks to Boris Zentner for
292 -Long options may now be negated either as '--nolong-option'
293 or '--no-long-option'. Thanks to Philip Newton for the suggestion.
295 -added flag --html-entities or -hent which controls the use of
296 Html::Entities for html formatting. Use --nohtml-entities or -nhent to
297 prevent the use of Html::Entities to encode special symbols. The
298 default is -hent. Html::Entities when formatting perl text to escape
299 special symbols. This may or may not be the right thing to do,
300 depending on browser/language combinations. Thanks to Burak Gursoy for
303 -Bareword strings with leading '-', like, '-foo' now count as 1 token
304 for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo}
305 are now all treated similarly. Thus, by default, OLD: $a{ -foo } will
306 now be NEW: $a{-foo}. Suggested by Mark Olesen.
308 -added 2 new flags to control spaces between keywords and opening parens:
309 -sak=s or --space-after-keyword=s, and
310 -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords.
312 The new default list of keywords which get a space is:
314 "my local our and or eq ne if else elsif until unless while for foreach
315 return switch case given when"
317 Use -sak=s and -nsak=s to add and remove keywords from this list,
320 Explanation: Stephen Hildrey noted that perltidy was being inconsistent
321 in placing spaces between keywords and opening parens, and sent a patch
322 to give user control over this. The above list was selected as being
323 a reasonable default keyword list. Previously, perltidy
324 had a hardwired list which also included these keywords:
326 push pop shift unshift join split die
328 but did not have 'our'. Example: if you prefer to make perltidy behave
329 exactly as before, you can include the following two lines in your
332 -sak="push pop local shift unshift join split die"
335 -Corrected html error in .toc file when -frm -html is used (extra ");
336 browsers were tolerant of it.
338 -Improved alignment of chains of binary and ?/: operators. Example:
352 -improved breakpoint choices involving '->'
354 -Corrected tokenization of things like ${#} or ${©}. For example,
355 ${©} is valid, but ${© } is a syntax error.
357 -Corrected minor tokenization errors with indirect object notation.
358 For example, 'new A::()' works now.
360 -Minor tokenization improvements; all perl code distributed with perl 5.8
361 seems to be parsed correctly except for one instance (lextest.t)
365 -Implemented scalar attributes. Thanks to Sean Tobin for noting this.
367 -Fixed glitch introduced in previous release where -pre option
368 was not outputting a leading html <pre> tag.
370 -Numerous minor improvements in vertical alignment, including the following:
372 -Improved alignment of opening braces in many cases. Needed for improved
373 switch/case formatting, and also suggested by Mark Olesen for sort/map/grep
374 formatting. For example:
379 sort { $a->[1] <=> $b->[1] }
380 map { [ $_, -M ] } @filenames;
385 sort { $a->[1] <=> $b->[1] }
386 map { [ $_, -M ] } @filenames;
388 -Eliminated alignments across unrelated statements. Example:
390 $borrowerinfo->configure( -state => 'disabled' );
391 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
394 $borrowerinfo->configure( -state => 'disabled' );
395 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
397 Thanks to Mark Olesen for suggesting this.
399 -Improved alignement of '='s in certain cases.
400 Thanks to Norbert Gruener for sending an example.
402 -Outdent-long-comments (-olc) has been re-instated as a default, since
403 it works much better now. Use -nolc if you want to prevent it.
405 -Added check for 'perltidy file.pl -o file.pl', which causes file.pl
406 to be lost. (The -b option should be used instead). Thanks to mreister
407 for reporting this problem.
410 -Switch/case or given/when syntax is now recognized. Its vertical alignment
411 is not great yet, but it parses ok. The words 'switch', 'case', 'given',
412 and 'when' are now treated as keywords. If this causes trouble with older
413 code, we could introduce a switch to deactivate it. Thanks to Stan Brown
414 and Jochen Schneider for recommending this.
416 -Corrected error parsing sub attributes with call parameters.
417 Thanks to Marc Kerr for catching this.
419 -Sub prototypes no longer need to be on the same line as sub names.
421 -a new flag -frm or --frames will cause html output to be in a
422 frame, with table of contents in the left panel and formatted source
423 in the right panel. Try 'perltidy -html -frm somemodule.pm' for example.
425 -The new default for -html formatting is to pass the pod through Pod::Html.
426 The result is syntax colored code within your pod documents. This can be
427 deactivated with -npod. Thanks to those who have written to discuss this,
428 particularly Mark Olesen and Hugh Myers.
430 -the -olc (--outdent-long-comments) option works much better. It now outdents
431 groups of consecutive comments together, and by just the amount needed to
432 avoid having any one line exceeding the maximum line length.
434 -block comments are now trimmed of trailing whitespace.
436 -if a directory specified with -opath does not exist, it will be created.
438 -a table of contents to packages and subs is output when -html is used.
439 Use -ntoc to prevent this.
441 -fixed an unusual bug in which a 'for' statement following a 'format'
442 statement was not correctly tokenized. Thanks to Boris Zentner for
445 -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray.
446 There were some speed issues. Suggested by Joerg Walter.
448 -The treatment of quoted wildcards (file globs) is now system-independent.
453 would match box.pl, box.pm, brinx.pm under any operating system. Of
454 course, anything unquoted will be subject to expansion by any shell.
456 -default color for keywords under -html changed from
457 SaddleBrown (#8B4513) to magenta4 (#8B008B).
459 -fixed an arg parsing glitch in which something like:
461 would trigger the help message and exit, rather than operate on the
465 -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to
466 overwrite the original file with the tidied output file. The original
467 file will be saved with a '.bak' extension (which can be changed with
468 -bext=s). Thanks to Rudi Farkas for the suggestion.
470 -An index to all subs is included at the top of -html output, unless
471 only the <pre> section is written.
473 -Anchor lines of the form <a name="mysub"></a> are now inserted at key points
474 in html output, such as before sub definitions, for the convenience of
475 postprocessing scripts. Suggested by Howard Owen.
477 -The cuddled-else (-ce) flag now also makes cuddled continues, like
480 while ( ( $pack, $file, $line ) = caller( $i++ ) ) {
486 Suggested by Simon Perreault.
488 -Fixed bug in which an extra blank line was added before an =head or
489 similar pod line after an __END__ or __DATA__ line each time
490 perltidy was run. Also, an extra blank was being added after
491 a terminal =cut. Thanks to Mike Birdsall for reporting this.
494 -Fixed bug in which space was inserted in a hyphenated hash key:
495 my $val = $myhash{USER-NAME};
497 my $val = $myhash{USER -NAME};
498 Thanks to an anonymous bug reporter at sourceforge.
500 -Fixed problem with the '-io' ('--indent-only') where all lines
501 were double spaced. Thanks to Nick Andrew for reporting this bug.
503 -Fixed tokenization error in which something like '-e1' was
506 -Corrected a rare problem involving older perl versions, in which
507 a line break before a bareword caused problems with 'use strict'.
508 Thanks to Wolfgang Weisselberg for noting this.
510 -More syntax error checking added.
512 -Outdenting labels (-ola) has been made the default, in order to follow the
513 perlstyle guidelines better. It's probably a good idea in general, but
514 if you do not want this, use -nola in your .perltidyrc file.
516 -Updated rules for padding logical expressions to include more cases.
517 Thanks to Wolfgang Weisselberg for helpful discussions.
519 -Added new flag -osbc (--outdent-static-block-comments) which will
520 outdent static block comments by 2 spaces (or whatever -ci equals).
521 Requested by Jon Robison.
524 -Corrected a bug, introduced in the previous release, in which some
525 closing side comments (-csc) could have incorrect text. This is
526 annoying but will be correct the next time perltidy is run with -csc.
528 -Implemented XHTML patch submitted by Ville Skyttä.
530 -Fixed bug where whitespace was being removed between 'Bar' and '()'
531 in a use statement like:
535 Thanks to Ville Skyttä for reporting this.
537 -Whenever possible, if a logical expression is broken with leading
538 '&&', '||', 'and', or 'or', then the leading line will be padded
539 with additional space to produce alignment. This has been on the
540 todo list for a long time; thanks to Frank Steinhauer for reminding
541 me to do it. Notice the first line after the open parens here:
545 !param("rules.to.$linecount")
546 && !param("rules.from.$linecount")
547 && !param("rules.subject.$linecount")
549 param("rules.fieldname.$linecount")
550 && param("rules.fieldval.$linecount")
552 && !param("rules.size.$linecount")
553 && !param("rules.custom.$linecount")
558 !param("rules.to.$linecount")
559 && !param("rules.from.$linecount")
560 && !param("rules.subject.$linecount")
562 param("rules.fieldname.$linecount")
563 && param("rules.fieldval.$linecount")
565 && !param("rules.size.$linecount")
566 && !param("rules.custom.$linecount")
570 -Corrected a mistokenization of variables for a package with a name
571 equal to a perl keyword. For example:
575 sub qx{print "Hello from my::qx\n";}
577 In this case, the leading 'my' was mistokenized as a keyword, and a
578 space was being place between 'my' and '::'. This has been
579 corrected. Thanks to Martin Sluka for discovering this.
581 -A new flag -bol (--break-at-old-logic-breakpoints)
582 has been added to control whether containers with logical expressions
583 should be broken open. This is the default.
585 -A new flag -bok (--break-at-old-keyword-breakpoints)
586 has been added to follow breaks at old keywords which return lists,
587 such as sort and map. This is the default.
589 -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to
590 follow breaks at trinary (conditional) operators. This is the default.
592 -A new flag -cab=n has been added to control breaks at commas after
593 '=>' tokens. The default is n=1, meaning break unless this breaks
594 open an existing on-line container.
596 -A new flag -boc has been added to allow existing list formatting
597 to be retained. (--break-at-old-comma-breakpoints). See updated manual.
599 -A new flag -iob (--ignore-old-breakpoints) has been added to
600 prevent the locations of old breakpoints from influencing the output
603 -Corrected problem where nested parentheses were not getting full
604 indentation. This has been on the todo list for some time; thanks
605 to Axel Rose for a snippet demonstrating this issue.
607 OLD: inner list is not indented
611 $ret->name, $user->username, $user->host,
612 $user->server->name, $user->nick, "H"
620 $ret->name, $user->username, $user->host,
621 $user->server->name, $user->nick, "H"
625 -Code cleaned up by removing the following unused, undocumented flags.
626 They should not be in any .perltidyrc files because they were just
627 experimental flags which were never documented. Most of them placed
628 artificial limits on spaces, and Wolfgang Weisselberg convinced me that
629 most of them they do more harm than good by causing unexpected results.
631 --maximum-continuation-indentation (-mci)
632 --maximum-whitespace-columns
633 --maximum-space-to-comment (-xsc)
634 --big-space-jump (-bsj)
636 -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and
637 Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's
640 -A new flag -isbc has been added for more control on comments. This flag
641 has the effect that if there is no leading space on the line, then the
642 comment will not be indented, and otherwise it may be. If both -ibc and
643 -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer
646 -A new document 'stylekey.pod' has been created to quickly guide new users
647 through the maze of perltidy style parameters. An html version is
648 on the perltidy web page. Take a look! It should be very helpful.
650 -Parameters for controlling 'vertical tightness' have been added:
651 -vt and -vtc are the main controls, but finer control is provided
652 with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical
653 tightness controls have also been added.
654 See updated manual and also see 'stylekey.pod'. Simple examples:
656 # perltidy -lp -vt=1 -vtc=1
657 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
658 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
660 # perltidy -lp -vt=1 -vtc=0
661 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
662 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
665 -Lists which do not format well in uniform columns are now better
666 identified and formated.
669 return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'},
670 $y + $ruler_info{'size'}, $x - $ruler_info{'size'},
671 $y + $ruler_info{'size'} );
676 $x + $ruler_info{'size'},
677 $y + $ruler_info{'size'},
678 $x - $ruler_info{'size'},
679 $y + $ruler_info{'size'}
683 radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ',
684 'None', 'Default', 'Default', 'Simple', 'Simple');
688 $b->{Init}->get_panel_ref,
689 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple');
691 -Corrected problem where an incorrect html filename was generated for
692 external calls to Tidy.pm module. Fixed incorrect html title when
693 Tidy.pm is called with IO::Scalar or IO::Array source.
695 -Output file permissons are now set as follows. An output script file
696 gets the same permission as the input file, except that owner
697 read/write permission is added (otherwise, perltidy could not be
698 rerun). Html output files use system defaults. Previously chmod 0755
699 was used in all cases. Thanks to Mark Olesen for bringing this up.
701 -Missing semicolons will not be added in multi-line blocks of type
702 sort, map, or grep. This brings perltidy into closer agreement
703 with common practice. Of course, you can still put semicolons
704 there if you like. Thanks to Simon Perreault for a discussion of this.
706 -Most instances of extra semicolons are now deleted. This is
707 particularly important if the -csc option is used. Thanks to Wolfgang
708 Weisselberg for noting this. For example, the following line
709 (produced by 'h2xs' :) has an extra semicolon which will now be
712 BEGIN { plan tests => 1 };
714 -New parameter -csce (--closing-side-comment-else-flag) can be used
715 to control what text is appended to 'else' and 'elsif' blocks.
716 Default is to just add leading 'if' text to an 'else'. See manual.
718 -The -csc option now labels 'else' blocks with additinal information
719 from the opening if statement and elsif statements, if space.
720 Thanks to Wolfgang Weisselberg for suggesting this.
722 -The -csc option will now remove any old closing side comments
723 below the line interval threshold. Thanks to Wolfgang Weisselberg for
726 -The abbreviation feature, which was broken in the previous version,
727 is now fixed. Thanks to Michael Cartmell for noting this.
729 -Vertical alignment is now done for '||=' .. somehow this was
733 -This version uses modules for the first time, and a standard perl
734 Makefile.PL has been supplied. However, perltidy may still be
735 installed as a single script, without modules. See INSTALL for
738 -The man page 'perl2web' has been merged back into the main 'perltidy'
739 man page to simplify installation. So you may remove that man page
740 if you have an older installation.
742 -Added patch from Axel Rose for MacPerl. The patch prompts the user
743 for command line arguments before calling the module
744 Perl::Tidy::perltidy.
746 -Corrected bug with '-bar' which was introduced in the previous
747 version. A closing block brace was being indented. Thanks to
748 Alexandros M Manoussakis for reporting this.
750 -New parameter '--entab-leading-whitespace=n', or '-et=n', has been
751 added for those who prefer tabs. This behaves different from the
752 existing '-t' parameter; see updated man page. Suggested by Mark
755 -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be
756 used to change the flags passed to perltidy in a syntax check.
757 See updated man page. Suggested by Mark Olesen.
759 -New parameter '--output-path=s' or '-opath=s' will cause output
760 files to be placed in directory s. See updated man page. Thanks for
761 Mark Olesen for suggesting this.
763 -New parameter --dump-profile (or -dpro) will dump to
764 standard output information about the search for a
765 configuration file, the name of whatever configuration file
766 is selected, and its contents. This should help debugging
767 config files, especially on different Windows systems.
769 -The -w parameter now notes possible errors of the form:
771 $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace
773 -Corrections added for a leading ':' and for leaving a leading 'tcsh'
774 line untouched. Mark Olesen reported that lines of this form were
775 accepted by perl but not by perltidy:
778 eval 'exec perl -wS $0 "$@"' # shell should exec 'perl'
779 unless 1; # but Perl should skip this one
781 Perl will silently swallow a leading colon on line 1 of a
782 script, and now perltidy will do likewise. For example,
783 this is a valid script, provided that it is the first line,
786 : print "Hello World\n";
788 Also, perltidy will now mark a first line with leading ':' followed by
789 '#' as type SYSTEM (just as a #! line), not to be formatted.
791 -List formatting improved for certain lists with special
792 initial terms, such as occur with 'printf', 'sprintf',
793 'push', 'pack', 'join', 'chmod'. The special initial term is
794 now placed on a line by itself. For example, perltidy -gnu
798 "C4", hex($SourceAddr[0]),
799 hex($SourceAddr[1]), hex($SourceAddr[2]),
805 hex($SourceAddr[0]), hex($SourceAddr[1]),
806 hex($SourceAddr[2]), hex($SourceAddr[3]));
810 @{$$self{states}}, '64', '66', '68',
811 '70', '72', '74', '76',
812 '78', '80', '82', '84',
813 '86', '88', '90', '92',
814 '94', '96', '98', '100',
821 '64', '66', '68', '70', '72', '74', '76',
822 '78', '80', '82', '84', '86', '88', '90',
823 '92', '94', '96', '98', '100', '102', '104'
826 -Lists of complex items, such as matricies, are now detected
827 and displayed with just one item per row:
830 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
831 [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ],
836 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
837 [ 1, tan( deg2rad($a) ), 0 ],
838 [ tan( deg2rad($b) ), 1, 0 ],
842 -The perl syntax check will be turned off for now when input is from
843 standard input or standard output. The reason is that this requires
844 temporary files, which has produced far too many problems during
845 Windows testing. For example, the POSIX module under Windows XP/2000
846 creates temporary names in the root directory, to which only the
847 administrator should have permission to write.
849 -Merged patch sent by Yves Orton to handle appropriate
850 configuration file locations for different Windows varieties
851 (2000, NT, Me, XP, 95, 98).
853 -Added patch to properly handle a for/foreach loop without
854 parens around a list represented as a qw. I didn't know this
855 was possible until Wolfgang Weisselberg pointed it out:
857 foreach my $key qw\Uno Due Tres Quadro\ {
861 But Perl will give a syntax error without the $ variable; ie this will
864 foreach qw\Uno Due Tres Quadro\ {
868 -Merged Windows version detection code sent by Yves Orton. Perltidy
869 now automatically turns off syntax checking for Win 9x/ME versions,
870 and this has solved a lot of robustness problems. These systems
871 cannot reliably handle backtick operators. See man page for
874 -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid
875 output filenames were being created in some cases).
877 -Numerous minor improvements have been made for -lp style indentation.
879 -Long C-style 'for' expressions will be broken after each ';'.
881 'perltidy -gnu' gives:
884 for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0
885 and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()))
888 for ($status = $db->seq($key, $value, R_CURSOR()) ;
889 $status == 0 and $key eq $origkey ;
890 $status = $db->seq($key, $value, R_NEXT()))
892 -For the -lp option, a single long term within parens
893 (without commas) now has better alignment. For example,
897 $self->throw("Must specify a known host, not $location,"
898 . " possible values ("
899 . join (",", sort keys %hosts) . ")");
902 $self->throw("Must specify a known host, not $location,"
903 . " possible values ("
904 . join (",", sort keys %hosts) . ")");
907 -This version is about 20 percent faster than the previous
908 version as a result of optimization work. The largest gain
909 came from switching to a dispatch hash table in the
912 -perltidy -html will check to see if HTML::Entities is
913 installed, and if so, it will use it to encode unsafe
916 -Added flag -oext=ext to change the output file extension to
917 be different from the default ('tdy' or 'html'). For
920 perltidy -html -oext=htm filename
922 will produce filename.htm
924 -Added flag -cscw to issue warnings if a closing side comment would replace
925 an existing, different side comments. See the man page for details.
926 Thanks to Peter Masiar for helpful discussions.
928 -Corrected tokenization error of signed hex/octal/binary numbers. For
929 example, the first hex number below would have been parsed correctly
930 but the second one was not:
931 if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { }
933 -'**=' was incorrectly tokenized as '**' and '='. This only
934 caused a problem with the -extrude opton.
936 -Corrected a divide by zero when -extrude option is used
938 -The flag -w will now contain all errors reported by 'perl -c' on the
939 input file, but otherwise they are not reported. The reason is that
940 perl will report lots of problems and syntax errors which are not of
941 interest when only a small snippet is being formatted (such as missing
942 modules and unknown bare words). Perltidy will always report all
943 significant syntax errors that it finds, such as unbalanced braces,
944 unless the -q (quiet) flag is set.
946 -Merged modifications created by Hugh Myers into perltidy.
947 These include a 'streamhandle' routine which allows perltidy
948 as a module to operate on input and output arrays and strings
949 in addition to files. Documentation and new packaging as a
950 module should be ready early next year; This is an elegant,
951 powerful update; many thanks to Hugh for contributing it.
954 -added a tentative patch which tries to keep any existing breakpoints
955 at lines with leading keywords map,sort,eval,grep. The idea is to
956 improve formatting of sequences of list operations, as in a schwartzian
960 my @sorted = map { $_->[0] }
961 sort { $a->[1] <=> $b->[1] }
962 map { [ $_, rand ] } @list;
966 map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
969 my @sorted = map { $_->[0] }
970 sort { $a->[1] <=> $b->[1] }
971 map { [ $_, rand ] } @list;
973 The new alignment is not as nice as the input, but this is an improvement.
974 Thanks to Yves Orton for this suggestion.
976 -modified indentation logic so that a line with leading opening paren,
977 brace, or square bracket will never have less indentation than the
978 line with the corresponding opening token. Here's a simple example:
982 -text => "New Document",
983 -command => \&new_document
989 Note how the closing ');' is lined up with the first line, even
990 though it closes a paren in the 'pack' line. That seems wrong.
994 -text => "New Document",
995 -command => \&new_document
1001 This seems nicer: you can up-arrow with an editor and arrive at the
1002 opening 'pack' line.
1004 -corrected minor glitch in which cuddled else (-ce) did not get applied
1005 to an 'unless' block, which should look like this:
1013 Thanks to Jeremy Mates for reporting this.
1015 -The man page has been reorganized to parameters easier to find.
1017 -Added check for multiple definitions of same subroutine. It is easy
1018 to introduce this problem when cutting and pasting. Perl does not
1019 complain about it, but it can lead to disaster.
1021 -The command -pro=filename or -profile=filename may be used to specify a
1022 configuration file which will override the default name of .perltidyrc.
1023 There must not be a space on either side of the '=' sign. I needed
1024 this to be able to easily test perltidy with a variety of different
1025 configuration files.
1027 -Side comment alignment has been improved somewhat across frequent level
1028 changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg
1029 for pointing out this problem. For example:
1032 if ( ref $self ) { # Called as a method
1035 else { # Regular procedure call
1041 if ( ref $self ) { # Called as a method
1044 else { # Regular procedure call
1049 -New command -ssc (--static-side-comment) and related command allows
1050 side comments to be spaced close to preceding character. This is
1051 useful for displaying commented code as side comments.
1053 -New command -csc (--closing-side-comment) and several related
1054 commands allow comments to be added to (and deleted from) any or all
1055 closing block braces. This can be useful if you have to maintain large
1056 programs, especially those that you didn't write. See updated man page.
1057 Thanks to Peter Masiar for this suggestion. For a simple example:
1062 if ( !defined( $_[0] ) ) {
1063 print("Hello, World\n");
1066 print( $_[0], "\n" );
1070 This added '## end sub foo' to the closing brace.
1071 To remove it, perltidy -ncsc.
1073 -New commands -ola, for outdenting labels, and -okw, for outdenting
1074 selected control keywords, were implemented. See the perltidy man
1075 page for details. Thanks to Peter Masiar for this suggestion.
1077 -Hanging side comment change: a comment will not be considered to be a
1078 hanging side comment if there is no leading whitespace on the line.
1079 This should improve the reliability of identifying hanging side comments.
1080 Thanks to Peter Masiar for this suggestion.
1082 -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc
1083 (outdent-long-comments), have been added. The original -oll
1084 (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc.
1085 The new default is just -olq. This was necessary to avoid inconsistency with
1086 the new static block comment option.
1088 -Static block comments: to provide a way to display commented code
1089 better, the convention is used that comments with a leading '##' should
1090 not be formatted as usual. Please see '-sbc' (or '--static-block-comment')
1091 for documentation. It can be deactivated with with -nsbc, but
1092 should not normally be necessary. Thanks to Peter Masiar for this
1095 -Two changes were made to help show structure of complex lists:
1096 (1) breakpoints are forced after every ',' in a list where any of
1097 the list items spans multiple lines, and
1098 (2) List items which span multiple lines now get continuation indentation.
1100 The following example illustrates both of these points. Many thanks to
1101 Wolfgang Weisselberg for this snippet and a discussion of it; this is a
1102 significant formatting improvement. Note how it is easier to see the call
1103 parameters in the NEW version:
1106 assert( __LINE__, ( not defined $check )
1109 or $check eq "old", "Error in parameters",
1110 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1111 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1112 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" );
1117 ( not defined $check )
1121 "Error in parameters",
1122 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1123 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1124 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef"
1127 Another example shows how this helps displaying lists:
1130 %{ $self->{COMPONENTS} } = (
1132 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1134 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1137 The structure is clearer with the added indentation:
1140 %{ $self->{COMPONENTS} } = (
1142 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1144 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1147 -The structure of nested logical expressions is now displayed better.
1148 Thanks to Wolfgang Weisselberg for helpful discussions. For example,
1149 note how the status of the final 'or' is displayed in the following:
1153 and null( $op->sibling )
1154 and $op->ppaddr eq "pp_null"
1155 and class($op) eq "UNOP"
1156 and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/
1157 and $op->first->first->sibling->ppaddr eq "pp_lineseq" )
1158 or ( $op->first->ppaddr eq "pp_lineseq"
1159 and not null $op->first->first->sibling
1160 and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) );
1165 and null( $op->sibling )
1166 and $op->ppaddr eq "pp_null"
1167 and class($op) eq "UNOP"
1170 $op->first->ppaddr =~ /^pp_(and|or)$/
1171 and $op->first->first->sibling->ppaddr eq "pp_lineseq"
1173 or ( $op->first->ppaddr eq "pp_lineseq"
1174 and not null $op->first->first->sibling
1175 and $op->first->first->sibling->ppaddr eq "pp_unstack" )
1179 -A break will always be put before a list item containing a comma-arrow.
1180 This will improve formatting of mixed lists of this form:
1184 'text', 225, 20, -text => 'A Simple Plot',
1192 -text => 'A Simple Plot',
1197 -For convenience, the command -dac (--delete-all-comments) now also
1198 deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod
1199 to a '.TEE' file. Complete control over the treatment of pod and
1200 comments is still possible, as described in the updated help message
1203 -The logic which breaks open 'containers' has been rewritten to be completely
1204 symmetric in the following sense: if a line break is placed after an opening
1205 {, [, or (, then a break will be placed before the corresponding closing
1206 token. Thus, a container either remains closed or is completely cracked
1209 -Improved indentation of parenthesized lists. For example,
1214 atan2( $GPSTempCompLong - $GPSLongitude,
1215 $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 );
1218 $GPSCompCourse = int(
1220 $GPSTempCompLong - $GPSLongitude,
1221 $GPSLatitude - $GPSTempCompLat
1222 ) * 180 / 3.14159265
1225 Further improvements will be made in future releases.
1227 -Some improvements were made in formatting small lists.
1229 -Correspondence between Input and Output line numbers reported in a
1230 .LOG file should now be exact. They were sometimes off due to the size
1231 of intermediate buffers.
1233 -Corrected minor tokenization error in which a ';' in a foreach loop
1234 control was tokenized as a statement termination, which forced a
1247 foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) {
1251 -Corrected a problem with reading config files, in which quote marks were not
1252 stripped. As a result, something like -wba="&& . || " would have the leading
1253 quote attached to the && and not work correctly. A workaround for older
1254 versions is to place a space around all tokens within the quotes, like this:
1257 -Removed any existing space between a label and its ':'
1260 This was necessary because the label and its colon are a single token.
1262 -Corrected tokenization error for the following (highly non-recommended)
1264 $user = @vars[1] / 100;
1266 -Resolved cause of a difference between perltidy under perl v5.6.1 and
1267 5.005_03; the problem was different behavior of \G regex position
1271 -Corrected a bug in which a break was not being made after a full-line
1272 comment within a short eval/sort/map/grep block. A flag was not being
1273 zeroed. The syntax error check catches this. Here is a snippet which
1274 illustrates the bug:
1277 #open Socket to Dispatcher
1278 $sock = &OpenSocket;
1281 The formatter mistakenly thought that it had found the following
1284 eval {#open Socket to Dispatcher$sock = &OpenSocket; };
1286 The patch fixes this. Many thanks to Henry Story for reporting this bug.
1288 -Changes were made to help diagnose and resolve problems in a
1290 (1) processing of command parameters has been into two separate
1291 batches so that any errors in a .perltidyrc file can be localized.
1292 (2) commands --help, --version, and as many of the --dump-xxx
1293 commands are handled immediately, without any command line processing
1295 (3) Perltidy will ignore any commands in the .perltidyrc file which
1296 cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt
1297 -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful
1298 suggestions regarding these updates.
1300 -Syntax check has been reinstated as default for MSWin32 systems. This
1301 way Windows 2000 users will get syntax check by default, which seems
1302 like a better idea, since the number of Win 95/98 systems will be
1303 decreasing over time. Documentation revised to warn Windows 95/98
1304 users about the problem with empty '&1'. Too bad these systems
1305 all report themselves as MSWin32.
1308 -Fixed tokenization error in which a method call of the form
1312 got a space before the '::' like this:
1316 Thanks to David Holden for reporting this.
1318 -Added -html control over pod text, using a new abbreviation 'pd'. See
1319 updated perl2web man page. The default is to use the color of a comment,
1320 but italicized. Old .css style sheets will need a new line for
1321 .pd to use this. The old color was the color of a string, and there
1324 -.css lines are now printed in sorted order.
1326 -Fixed interpolation problem where html files had '$input_file' as title
1327 instead of actual input file name. Thanks to Simon Perreault for finding
1328 this and sending a patch, and also to Tobias Weber.
1330 -Breaks will now have the ':' placed at the start of a line,
1331 one per line by default because this shows logical structure
1332 more clearly. This coding has been completely redone. Some
1333 examples of new ?/: formatting:
1336 wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) :
1337 $dir::cwd->lookup( $_[0] )->path;
1341 ? map( $dir::cwd->lookup($_)->path, @_ )
1342 : $dir::cwd->lookup( $_[0] )->path;
1348 } : { a => 6, b => 8 };
1356 : { a => 6, b => 8 };
1359 $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" :
1360 "Hunk #$self->{hunk} failed--$@");
1363 $self->note($self->{skip}
1364 ? "Hunk #$self->{hunk} ignored at 1.\n"
1365 : "Hunk #$self->{hunk} failed--$@");
1369 $opts{"t"} ? 'title' :
1370 $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title';
1374 $opts{"t"} ? 'title'
1375 : $opts{"s"} ? 'subject'
1376 : $opts{"a"} ? 'author'
1379 You can use -wba=':' to recover the previous default which placed ':'
1380 at the end of a line. Thanks to Michael Cartmell for helpful
1381 discussions and examples.
1383 -Tokenizer updated to do syntax checking for matched ?/: pairs. Also,
1384 the tokenizer now outputs a unique serial number for every balanced
1385 pair of brace types and ?/: pairs. This greatly simplifies the
1388 -Long lines with repeated 'and', 'or', '&&', '||' will now have
1389 one such item per line. For example:
1392 if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x
1393 || ( -e $archive && $opt_r ) )
1395 ( $pAr, $pNames ) = readAr($archive);
1404 || ( -e $archive && $opt_r ) )
1406 ( $pAr, $pNames ) = readAr($archive);
1410 if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x
1411 && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y )
1414 if ( $vp->{X0} + 4 <= $x
1415 && $vp->{X0} + $vp->{W} - 4 >= $x
1416 && $vp->{Y0} + 4 <= $y
1417 && $vp->{Y0} + $vp->{H} - 4 >= $y )
1419 -Long lines with multiple concatenated tokens will have concatenated
1420 terms (see below) placed one per line, except for short items. For
1425 "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:"
1426 . $ib->crc . ": " . $ib->model() . "\n";
1429 $report .= "Device type:"
1430 . $ib->family . " ID:"
1431 . $ib->serial . " CRC:"
1433 . $ib->crc . ": " . "\n";
1435 NOTE: at present 'short' means 8 characters or less. There is a
1436 tentative flag to change this (-scl), but it is undocumented and
1437 is likely to be changed or removed later, so only use it for testing.
1438 In the above example, the tokens " ID:", " CRC:", and "\n" are below
1441 -If a line which is short enough to fit on a single line was
1442 nevertheless broken in the input file at a 'good' location (see below),
1443 perltidy will try to retain a break. For example, the following line
1444 will be formatted as:
1447 or die "Cannot open $file ($!)";
1449 if it was broken in the input file, and like this if not:
1451 open SUM, "<$file" or die "Cannot open $file ($!)";
1453 GOOD: 'good' location means before 'and','or','if','unless','&&','||'
1455 The reason perltidy does not just always break at these points is that if
1456 there are multiple, similar statements, this would preclude alignment. So
1457 rather than check for this, perltidy just tries to follow the input style,
1458 in the hopes that the author made a good choice. Here is an example where
1459 we might not want to break before each 'if':
1461 ($Locale, @Locale) = ($English, @English) if (@English > @Locale);
1462 ($Locale, @Locale) = ($German, @German) if (@German > @Locale);
1463 ($Locale, @Locale) = ($French, @French) if (@French > @Locale);
1464 ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale);
1466 -Added wildcard file expansion for systems with shells which lack this.
1467 Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers
1468 for suggesting this. This uses builtin glob() for now; I may change that.
1470 -Added new flag -sbl which, if specified, overrides the value of -bl
1471 for opening sub braces. This allows formatting of this type:
1477 if (!defined($_[0])) {
1478 print("Hello, World\n");
1484 Requested by Don Alexander.
1486 -Fixed minor parsing error which prevented a space after a $$ variable
1487 (pid) in some cases. Thanks to Michael Cartmell for noting this.
1492 -Improved line break choices 'and' and 'or' to display logic better.
1496 exists $self->{'build_dir'} and push @e,
1497 "Unwrapped into directory $self->{'build_dir'}";
1500 exists $self->{'build_dir'}
1501 and push @e, "Unwrapped into directory $self->{'build_dir'}";
1503 -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains
1504 abbreviation for delete-side-comments; -dsm is new abbreviation for
1507 -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for
1510 -The default for Windows is, for now, not to do a 'perl -c' syntax
1511 check (but -syn will activate it). This is because of problems with
1512 command.com. James Freeman sent me a patch which tries to get around
1513 the problems, and it works in many cases, but testing revealed several
1514 issues that still need to be resolved. So for now, the default is no
1515 syntax check for Windows.
1517 -I added a -T flag when doing perl -c syntax check.
1518 This is because I test it on a large number of scripts from sources
1519 unknown, and who knows what might be hidden in initialization blocks?
1520 Also, deactivated the syntax check if perltidy is run as root. As a
1521 benign example, running the previous version of perltidy on the
1522 following file would cause it to disappear:
1525 print "Bye, bye baby!\n";
1529 The new version will not let that happen.
1531 -I am contemplating (but have not yet implemented) making '-lp' the
1532 default indentation, because it is stable now and may be closer to how
1533 perl is commonly formatted. This could be in the next release. The
1534 reason that '-lp' was not the original default is that the coding for
1535 it was complex and not ready for the initial release of perltidy. If
1536 anyone has any strong feelings about this, I'd like to hear. The
1537 current default could always be recovered with the '-nlp' flag.
1541 - sub definition names are now specially colored, red by default.
1542 The letter 'm' is used to identify them.
1543 - keyword 'sub' now has color of other keywords.
1544 - restored html keyword color to __END__ and __DATA__, which was
1545 accidentally removed in the previous version.
1547 -A new -se (--standard-error-output) flag has been implemented and
1548 documented which causes all errors to be written to standard output
1549 instead of a .ERR file.
1551 -A new -w (--warning-output) flag has been implemented and documented
1552 which causes perltidy to output certain non-critical messages to the
1553 error output file, .ERR. These include complaints about pod usage,
1554 for example. The default is to not include these.
1556 NOTE: This replaces an undocumented -w=0 or --warning-level flag
1557 which was tentatively introduced in the previous version to avoid some
1558 unwanted messages. The new default is the same as the old -w=0, so
1559 that is no longer needed.
1561 -Improved syntax checking and corrected tokenization of functions such
1562 as rand, srand, sqrt, ... These can accept either an operator or a term
1563 to their right. This has been corrected.
1565 -Corrected tokenization of semicolon: testing of the previous update showed
1566 that the semicolon in the following statement was being mis-tokenized. That
1567 did no harm, other than adding an extra blank space, but has been corrected.
1569 for (sort {strcoll($a,$b);} keys %investments) {
1573 -New syntax check: after wasting 5 minutes trying to resolve a syntax
1574 error in which I had an extra terminal ';' in a complex for (;;) statement,
1575 I spent a few more minutes adding a check for this in perltidy so it won't
1578 -The behavior of --break-before-subs (-bbs) and --break-before-blocks
1579 (-bbb) has been modified. Also, a new control parameter,
1580 --long-block-line-count=n (-lbl=n) has been introduced to give more
1581 control on -bbb. This was previously a hardwired value. The reason
1582 for the change is to reduce the number of unwanted blank lines that
1583 perltidy introduces, and make it less erratic. It's annoying to remove
1584 an unwanted blank line and have perltidy put it back. The goal is to
1585 be able to sprinkle a few blank lines in that dense script you
1586 inherited from Bubba. I did a lot of experimenting with different
1587 schemes for introducing blank lines before and after code blocks, and
1588 decided that there is no really good way to do it. But I think the new
1589 scheme is an improvement. You can always deactivate this with -nbbb.
1590 I've been meaning to work on this; thanks to Erik Thaysen for bringing
1593 -The .LOG file is seldom needed, and I get tired of deleting them, so
1594 they will now only be automatically saved if perltidy thinks that it
1595 made an error, which is almost never. You can still force the logfile
1596 to be saved with -log or -g.
1598 -Improved method for computing number of columns in a table. The old
1599 method always tried for an even number. The new method allows odd
1600 numbers when it is obvious that a list is not a hash initialization
1604 $name, $xsargs, $parobjs, $optypes,
1605 $hasp2child, $pmcode, $hdrcode, $inplacecode,
1606 $globalnew, $callcopy
1611 $name, $xsargs, $parobjs, $optypes, $hasp2child,
1612 $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy
1616 -I fiddled with the list threshold adjustment, and some small lists
1617 look better now. Here is the change for one of the lists in test file
1621 ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%",
1622 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%");
1626 "in", "in", "pt", "pt", "pc", "pi",
1627 "mm", "mm", "cm", "cm", "\\hsize", "%",
1628 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"
1631 -Improved -lp formatting at '=' sign. A break was always being added after
1632 the '=' sign in a statement such as this, (to be sure there was enough room
1633 for the parameters):
1638 $biblionumber, $constraint,
1642 The updated version doesn't do this unless the space is really needed:
1644 new: my $fee = CalcReserveFee(
1646 $biblionumber, $constraint,
1650 -I updated the tokenizer to allow $#+ and $#-, which seem to be new to
1651 Perl 5.6. Some experimenting with a recent version of Perl indicated
1652 that it allows these non-alphanumeric '$#' array maximum index
1653 varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#:
1654 seems to be valid in older versions of Perl.
1656 -Fixed a rare formatting problem with -lp (and -gnu) which caused
1657 excessive indentation.
1659 -Many additional syntax checks have been added.
1661 -Revised method for testing here-doc target strings; the following
1662 was causing trouble with a regex test because of the '*' characters:
1666 Perl seems to allow almost anything to be a here doc target, so an
1667 exact string comparison is now used.
1669 -Made update to allow underscores in binary numbers, like '0b1100_0000'.
1671 -Corrected problem with scanning certain module names; a blank space was
1672 being inserted after 'warnings' in the following:
1673 use warnings::register;
1674 The problem was that warnings (and a couple of other key modules) were
1675 being tokenized as keywords. They should have just been identifiers.
1677 -Corrected tokenization of indirect objects after sort, system, and exec,
1678 after testing produced an incorrect error message for the following
1680 print sort $sortsubref @list;
1682 -Corrected minor problem where a line after a format had unwanted
1683 extra continuation indentation.
1685 -Delete-block-comments (and -dac) now retain any leading hash-bang line
1687 -Update for -lp (and -gnu) to not align the leading '=' of a list
1688 with a previous '=', since this interferes with alignment of parameters.
1690 old: my $hireDay = new Date;
1697 new: my $hireDay = new Date;
1704 -Modifications made to display tables more compactly when possible,
1705 without adding lines. For example,
1707 '1', "I", '2', "II", '3', "III", '4', "IV",
1708 '5', "V", '6', "VI", '7', "VII", '8', "VIII",
1711 '1', "I", '2', "II", '3', "III",
1712 '4', "IV", '5', "V", '6', "VI",
1713 '7', "VII", '8', "VIII", '9', "IX"
1715 -Corrected minor bug in which -pt=2 did not keep the right paren tight
1716 around a '++' or '--' token, like this:
1718 for ($i = 0 ; $i < length $key ; $i++ )
1720 The formatting for this should be, and now is:
1722 for ($i = 0 ; $i < length $key ; $i++)
1724 Thanks to Erik Thaysen for noting this.
1726 -Discovered a new bug involving here-docs during testing! See BUGS.html.
1728 -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature).
1729 However, the attributes and prototypes must still be on the same line
1733 -Corrected minor, uncommon bug found during routine testing, in which a
1734 blank got inserted between a function name and its opening paren after
1735 a file test operator, but only in the case that the function had not
1736 been previously seen. Perl uses the existance (or lack thereof) of
1737 the blank to guess if it is a function call. That is,
1738 if (-l pid_filename()) {
1740 if (-l pid_filename ()) {
1741 which is a syntax error if pid_filename has not been seen by perl.
1743 -If the AutoLoader module is used, perltidy will continue formatting
1744 code after seeing an __END__ line. Use -nlal to deactivate this feature.
1745 Likewise, if the SelfLoader module is used, perltidy will continue
1746 formatting code after seeing a __DATA__ line. Use -nlsl to
1747 deactivate this feature. Thanks to Slaven Rezic for this suggestion.
1749 -pod text after __END__ and __DATA__ is now identified by perltidy
1750 so that -dp works correctly. Thanks to Slaven Rezic for this suggestion.
1752 -The first $VERSION line which might be eval'd by MakeMaker
1753 is now passed through unchanged. Use -npvl to deactivate this feature.
1754 Thanks to Manfred Winter for this suggestion.
1756 -Improved indentation of nested parenthesized expressions. Tests have
1757 given favorable results. Thanks to Wolfgang Weisselberg for helpful
1761 -Fixed a very rare problem in which an unwanted semicolon was inserted
1762 due to misidentification of anonymous hash reference curly as a code
1763 block curly. (No instances of this have been reported; I discovered it
1764 during testing). A workaround for older versions of perltidy is to use
1767 -Added -icb (-indent-closing-brace) parameter to indent a brace which
1768 terminates a code block to the same level as the previous line.
1769 Suggested by Andrew Cutler. For example,
1778 -Rewrote error message triggered by an unknown bareword in a print or
1779 printf filehandle position, and added flag -w=0 to prevent issuing this
1780 error message. Suggested by Byron Jones.
1782 -Added modification to align a one-line 'if' block with similar
1783 following 'elsif' one-line blocks, like this:
1784 if ( $something eq "simple" ) { &handle_simple }
1785 elsif ( $something eq "hard" ) { &handle_hard }
1786 (Suggested by Wolfgang Weisselberg).
1789 -Eliminated all constants with leading underscores because perl 5.005_03
1790 does not support that. For example, _SPACES changed to XX_SPACES.
1791 Thanks to kromJx for this update.
1794 -the directory of test files has been moved to a separate distribution
1795 file because it is getting large but is of little interest to most users.
1796 For the current distribution:
1797 perltidy-20010701.tgz contains the source and docs for perltidy
1798 perltidy-20010701-test.tgz contains the test files
1800 -fixed bug where temporary file perltidy.TMPI was not being deleted
1801 when input was from stdin.
1803 -adjusted line break logic to not break after closing brace of an
1804 eval block (suggested by Boris Zentner).
1806 -added flag -gnu (--gnu-style) to give an approximation to the GNU
1807 style as sometimes applied to perl. The programming style in GNU
1808 'automake' was used as a guide in setting the parameters; these
1809 parameters will probably be adjusted over time.
1811 -an empty code block now has one space for emphasis:
1812 if ( $cmd eq "bg_untested" ) {} # old
1813 if ( $cmd eq "bg_untested" ) { } # new
1814 If this bothers anyone, we could create a parameter.
1816 -the -bt (--brace-tightness) parameter has been split into two
1817 parameters to give more control. -bt now applies only to non-BLOCK
1818 braces, while a new parameter -bbt (block-brace-tightness) applies to
1819 curly braces which contain code BLOCKS. The default value is -bbt=0.
1821 -added flag -icp (--indent-closing-paren) which leaves a statment
1822 termination of the form );, };, or ]; indented with the same
1823 indentation as the previous line. For example,
1825 @month_of_year = ( # default, or -nicp
1826 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1830 @month_of_year = ( # -icp
1831 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
1835 -Vertical alignment updated to synchronize with tokens &&, ||,
1836 and, or, if, unless. Allowable space before forcing
1837 resynchronization has been increased. (Suggested by Wolfgang
1840 -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold,
1841 and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There
1842 was no way to negate these previously. html documentation updated and
1843 corrected. (Suggested by Wolfgang Weisselberg).
1845 -Some modifications have been made which improve the -lp formatting in
1848 -Perltidy now retains or creates a blank line after an =cut to keep
1849 podchecker happy (Suggested by Manfred H. Winter). This appears to be
1850 a glitch in podchecker, but it was annoying.
1853 -Added -bli flag to give continuation indentation to braces, like this
1857 extra_indentation();
1860 -Corrected an error with the tab (-t) option which caused the last line
1861 of a multi-line quote to receive a leading tab. This error was in
1862 version 2001 06 08 but not 2001 04 06. If you formatted a script
1863 with -t with this version, please check it by running once with the
1864 -chk flag and perltidy will scan for this possible error.
1866 -Corrected an invalid pattern (\R should have been just R), changed
1867 $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected
1868 several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg,
1869 2001-06-12, for catching these errors.
1871 -A '-bar' flag has been added to require braces to always be on the
1872 right, even for multi-line if and foreach statements. For example,
1873 the default formatting of a long if statement would be:
1875 if ($bigwasteofspace1 && $bigwasteofspace2
1876 || $bigwasteofspace3 && $bigwasteofspace4)
1881 With -bar, the formatting is:
1883 if ($bigwasteofspace1 && $bigwasteofspace2
1884 || $bigwasteofspace3 && $bigwasteofspace4) {
1887 Suggested by Eli Fidler 2001-06-11.
1889 -Uploaded perltidy to sourceforge cvs 2001-06-10.
1891 -An '-lp' flag (--line-up-parentheses) has been added which causes lists
1892 to be indented with extra indentation in the manner sometimes
1893 associated with emacs or the GNU suggestions. Thanks to Ian Stuart for
1894 this suggestion and for extensive help in testing it.
1896 -Subroutine call parameter lists are now formatted as other lists.
1897 This should improve formatting of tables being passed via subroutine
1898 calls. This will also cause full indentation ('-i=n, default n= 4) of
1899 continued parameter list lines rather than just the number of spaces
1900 given with -ci=n, default n=2.
1902 -Added support for hanging side comments. Perltidy identifies a hanging
1903 side comment as a comment immediately following a line with a side
1904 comment or another hanging side comment. This should work in most
1905 cases. It can be deactivated with --no-hanging-side-comments (-nhsc).
1906 The manual has been updated to discuss this. Suggested by Brad
1907 Eisenberg some time ago, and finally implemented.
1910 -fixed problem with parsing command parameters containing quoted
1911 strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07).
1913 -added two command line flags, --want-break-after and
1914 --want-break-before, which allow changing whether perltidy
1915 breaks lines before or after any operators. Please see the revised
1916 man pages for details.
1918 -added system-wide configuration file capability.
1919 If perltidy does not find a .perltidyrc command line file in
1920 the current directory, nor in the home directory, it now looks
1921 for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'.
1922 (Suggested by Roger Espel Llima 2001-05-31).
1924 -fixed problem in which spaces were trimmed from lines of a multi-line
1925 quote. (Reported by Roger Espel Llima 2001-05-30). This is an
1926 uncommon situation, but serious, because it could conceivably change
1927 the proper function of a script.
1929 -fixed problem in which a semicolon was incorrectly added within
1930 an anonymous hash. (Reported by A.C. Yardley, 2001-5-23).
1931 (You would know if this happened, because perl would give a syntax
1932 error for the resulting script).
1934 -fixed problem in which an incorrect error message was produced
1935 after a version number on a 'use' line, like this ( Reported
1936 by Andres Kroonmaa, 2001-5-14):
1938 use CGI 2.42 qw(fatalsToBrowser);
1940 Other than the extraneous error message, this bug was harmless.
1943 -fixed serious bug in which the last line of some multi-line quotes or
1944 patterns was given continuation indentation spaces. This may make
1945 a pattern incorrect unless it uses the /x modifier. To find
1946 instances of this error in scripts which have been formatted with
1947 earlier versions of perltidy, run with the -chk flag, which has
1948 been added for this purpose (SLH, 2001-04-05).
1950 ** So, please check previously formatted scripts by running with -chk
1953 -continuation indentation has been reprogrammed to be hierarchical,
1954 which improves deeply nested structures.
1956 -fixed problem with undefined value in list formatting (reported by Michael
1959 -Switched to graphical display of nesting in .LOG files. If an
1960 old format string was "(1 [0 {2", the new string is "{{(". This
1961 is easier to read and also shows the order of nesting.
1963 -added outdenting of cuddled paren structures, like ")->pack(".
1965 -added line break and outdenting of ')->' so that instead of
1968 -text => "perltidy",
1969 -relief => 'ridge')->pack;
1971 the current default is:
1974 -text => "perltidy",
1978 (requested by Michael Langner 2001-03-31; in the future this could
1979 be controlled by a command-line parameter).
1981 -revised list indentation logic, so that lists following an assignment
1982 operator get one full indentation level, rather than just continuation
1983 indentation. Also corrected some minor glitches in the continuation
1986 -Fixed problem with unwanted continuation indentation after a blank line
1987 (reported by Erik Thaysen 2001-03-28):
1989 -minor update to avoid stranding a single '(' on one line
1992 -corrected serious error tokenizing filehandles, in which a sub call
1993 after a print or printf, like this:
1994 print usage() and exit;
1996 print usage () and exit;
1997 Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun
1998 perltidy; it will look for this situation and issue a warning.
2000 -fixed another cuddled-else formatting bug (Reported by Craig Bourne)
2002 -added several diagnostic --dump routines
2004 -added token-level whitespace controls (suggested by Hans Ecke)
2007 -added support for special variables of the form ${^WANT_BITS}
2009 -space added between scalar and left paren in 'for' and 'foreach' loops,
2010 (suggestion by Michael Cartmell):
2012 for $i( 1 .. 20 ) # old
2013 for $i ( 1 .. 20 ) # new
2015 -html now outputs cascading style sheets (thanks to suggestion from
2018 -flags -o and -st now work with -html
2020 -added missing -html documentation for comments (noted by Alex Izvorski)
2022 -support for VMS added (thanks to Michael Cartmell for code patches and
2025 -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive
2026 testing by Michael Cartmell)
2028 -fixed problem where operand may be empty at line 3970
2029 (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen,
2030 Keith Marshall for bug reports)
2032 -fixed -ce bug (cuddled else), where lines like '} else {' were indented
2033 (Thanks to Shawn Stepper and Rick Measham for reporting this)
2036 -fixed undefined value in line 153 (only worked with -I set)
2037 (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others)
2039 -fixed undefined value in line 1069 (filehandle problem with perl versions <
2040 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber)
2043 -Initial announcement at freshmeat.net; started Change Log
2044 (Unfortunately this version was DOA, but it was fixed the next day)